Skip to content

Commit 2e5a011

Browse files
committed
update tagging/pypi push behavior
1 parent 57fa392 commit 2e5a011

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
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+
18
name: Build and Test
29

310
on:
411
push:
12+
branches:
13+
- main
514
tags:
6-
- '*'
15+
- 'v*'
716

817
jobs:
918
docker:
1019
runs-on: ubuntu-latest
11-
env:
12-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1320
steps:
1421
- uses: actions/checkout@v3
1522
- name: Checkout tags
1623
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
2131
- name: Checkout submodules
2232
shell: bash
2333
run: |
@@ -120,8 +130,16 @@ jobs:
120130
partis-test.py --paired --no-per-base-mutation --no-tree-gen
121131
fi
122132
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+
123141
- 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')
125143
run: |
126144
python -m pip install build twine
127145
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then

0 commit comments

Comments
 (0)