|
| 1 | +# Release workflow: |
| 2 | +# 1. merge dev into main |
| 3 | +# 2. git tag v<new-version> (on main) |
| 4 | +# 3. git push origin main --tags |
| 5 | +# CI runs on every push to main (tests only) and on v* tag pushes (tests + PyPI publish). |
| 6 | +# PyPI publish requires the tag to be on main. |
| 7 | + |
1 | 8 | name: Build and Test |
2 | 9 |
|
3 | 10 | on: |
4 | 11 | push: |
| 12 | + branches: |
| 13 | + - main |
5 | 14 | tags: |
6 | | - - '*' |
| 15 | + - 'v*' |
7 | 16 |
|
8 | 17 | jobs: |
9 | 18 | docker: |
10 | 19 | runs-on: ubuntu-latest |
11 | | - env: |
12 | | - ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
13 | 20 | steps: |
14 | 21 | - uses: actions/checkout@v3 |
15 | 22 | - name: Checkout tags |
16 | 23 | run: git fetch --unshallow origin +refs/tags/*:refs/tags/* |
17 | | - - name: Set git branch variable |
18 | | - run: echo ::set-env name=BRANCH::$(git branch --show-current) |
19 | | - - name: Set git tag variable |
20 | | - run: if [ $BRANCH == "main" ];then echo ::set-env name=TAG::$(git describe --tags);else echo ::set-env name=TAG::$BRANCH;fi |
| 24 | + - name: Set docker tag variable |
| 25 | + run: | |
| 26 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 27 | + echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 28 | + else |
| 29 | + echo "TAG=latest" >> $GITHUB_ENV |
| 30 | + fi |
21 | 31 | - name: Checkout submodules |
22 | 32 | shell: bash |
23 | 33 | run: | |
@@ -120,8 +130,16 @@ jobs: |
120 | 130 | partis-test.py --paired --no-per-base-mutation --no-tree-gen |
121 | 131 | fi |
122 | 132 |
|
| 133 | + - name: Verify tag is on main |
| 134 | + if: matrix.install-method == 'pip' && startsWith(github.ref, 'refs/tags/v') |
| 135 | + run: | |
| 136 | + if ! git branch -r --contains HEAD | grep -q 'origin/main'; then |
| 137 | + echo "ERROR: tag is not on main branch, skipping PyPI publish" |
| 138 | + exit 1 |
| 139 | + fi |
| 140 | +
|
123 | 141 | - name: Build and publish to PyPI |
124 | | - if: matrix.install-method == 'pip' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') # && matrix.os == 'ubuntu-latest' |
| 142 | + if: matrix.install-method == 'pip' && startsWith(github.ref, 'refs/tags/v') |
125 | 143 | run: | |
126 | 144 | python -m pip install build twine |
127 | 145 | if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then |
|
0 commit comments