Skip to content

Commit df1a35e

Browse files
Improve robustness of the GitHub Actions workflow. (#12)
* Run the build workflow on `push` to the main branch only. This fixes duplicate runs on pull requests from a branch not in a fork. * Simplify repository owner check and do not make a release on workflow dispatch. * Explicitly specify the commit to make the release on. Will not make a difference at present, but it should be explicit.
1 parent ee0bb54 commit df1a35e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.github/workflows/msys2-htslib-build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Build a statically linked htslib.dll under msys2
22
on:
33
push:
4+
branches:
5+
- main
46
paths:
57
- '.github/workflows/msys2-htslib-build.yml'
68
- 'patches/**'
@@ -56,7 +58,7 @@ jobs:
5658
release:
5759
name: release
5860
needs: build
59-
if: github.repository == 'TileDB-Inc/m2w64-htslib-build' && github.event_name != 'pull_request'
61+
if: github.repository_owner == 'TileDB-Inc' && github.event_name == 'push'
6062
runs-on: ubuntu-latest
6163
permissions:
6264
contents: write
@@ -70,4 +72,5 @@ jobs:
7072
- name: Create release
7173
env:
7274
GH_TOKEN: ${{ github.token }}
75+
GIT_REF: ${{ github.ref }}
7376
run: bash scripts/release.sh

scripts/release.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ then
1010
exit 1
1111
fi
1212

13+
if [[ -z "$GIT_REF" ]]
14+
then
15+
echo "The env var GIT_REF is missing"
16+
echo "Please define it as the reference to the commit to make the release on"
17+
exit 1
18+
fi
19+
1320
PACKAGE_VERSION=${PACKAGE_VERSION-1.15.1}
1421
RELEASE_VERSION=${RELEASE_VERSION-0}
1522
FULL_VERSION=${PACKAGE_VERSION}-${RELEASE_VERSION}
@@ -22,5 +29,6 @@ then
2229
gh release create ${FULL_VERSION} \
2330
--notes ${FULL_VERSION} \
2431
--title ${FULL_VERSION} \
32+
--target ${GIT_REF} \
2533
m2w64-htslib-${FULL_VERSION}.tar.gz
2634
fi

0 commit comments

Comments
 (0)