Skip to content

Commit 9537065

Browse files
committed
make release(s) on tag push, not main push
1 parent 833a963 commit 9537065

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

.github/workflows/cicd.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: ci/cd
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ '**' ]
6+
tags-ignore: [ '**' ]
67

78
jobs:
89

@@ -118,10 +119,10 @@ jobs:
118119

119120

120121
############################################################################
121-
# RELEASE
122+
# TAG NEW VERSION
122123
############################################################################
123124

124-
release:
125+
tag-new-version:
125126
# only run on main/master/default
126127
if: format('refs/heads/{0}', github.event.repository.default_branch) == github.ref
127128
needs: [
@@ -132,11 +133,12 @@ jobs:
132133
py-dependencies
133134
]
134135
runs-on: ubuntu-latest
135-
concurrency: release # prevent any possible race conditions
136+
concurrency: tag-new-version # prevent any possible race conditions
136137
steps:
137138
- uses: actions/checkout@v4
138139
with:
139140
fetch-depth: 0 # required to see tags and commits
141+
ref: ${{ github.sha }} # in case 'ref' (arg default) has been updated since start
140142
- uses: actions/setup-python@v5
141143
with:
142144
python-version: "${{ fromJSON(needs.py-versions.outputs.matrix)[0] }}"
@@ -146,28 +148,15 @@ jobs:
146148
with:
147149
force-patch-if-no-commit-token: true
148150
ignore-paths: |
149-
.github/**
150151
.gitignore
151152
assets/**
152153
dependencies-logs/**
153154
resources/foo/**
154155
155-
- uses: WIPACrepo/wipac-dev-py-build-action@main
156+
- name: Tag New Version
156157
if: steps.next-version.outputs.version != ''
157-
with:
158-
version: ${{ steps.next-version.outputs.version }}
159-
160-
- uses: softprops/action-gh-release@v2
161-
if: steps.next-version.outputs.version != ''
162-
with:
163-
files: dist/*
164-
tag_name: v${{ steps.next-version.outputs.version }}
165-
generate_release_notes: true
166-
env:
167-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168-
169-
- uses: pypa/gh-action-pypi-publish@release/v1
170-
if: steps.next-version.outputs.version != ''
171-
with:
172-
user: __token__
173-
password: ${{ secrets.PYPI_TOKEN }}
158+
run: |
159+
set -euo pipefail
160+
echo "now: $(date -u +"%Y-%m-%dT%H:%M:%S.%3N")"
161+
git tag ${{ steps.next-version.outputs.version }}
162+
git push origin ${{ steps.next-version.outputs.version }}

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches-ignore: [ '**' ]
6+
tags: [ 'v*.*.*' ]
7+
8+
jobs:
9+
10+
py-versions:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.versions.outputs.matrix }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- id: versions
17+
uses: WIPACrepo/wipac-dev-py-versions-action@v2.5
18+
19+
release:
20+
if: github.ref_type == 'tag' # redundant b/c workflow's 'on'
21+
needs: [ py-versions ]
22+
runs-on: ubuntu-latest
23+
concurrency: release # prevent any possible race conditions
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # required to see tags and commits
28+
ref: ${{ github.sha }} # in case 'ref' (arg default) has been updated since start
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: "${{ fromJSON(needs.py-versions.outputs.matrix)[0] }}"
32+
33+
- uses: WIPACrepo/wipac-dev-py-build-action@main
34+
35+
- uses: softprops/action-gh-release@v2
36+
# uses 'github.ref_name' as associated tag
37+
with:
38+
files: dist/*
39+
generate_release_notes: true
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- uses: pypa/gh-action-pypi-publish@release/v1
44+
with:
45+
user: __token__
46+
password: ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)