monetise Claude Opus 5 commited on
Commit
e440b9a
·
1 Parent(s): dc72c7a

CI: tag and release when CITATION.cff changes

Browse files

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

.github/workflows/release-on-version-change.yml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Push to main with a new version in CITATION.cff and this tags it and publishes
2
+ # the release; the Zenodo webhook on this repository then archives that release
3
+ # and mints its DOI. Nothing runs when the version is unchanged, so an ordinary
4
+ # commit never creates a release.
5
+ #
6
+ # Pre-release lines (tags such as v5.0-pre.x) stay manual: CITATION.cff carries
7
+ # the stable version, and this workflow only ever tags that one.
8
+
9
+ name: Release on version change
10
+
11
+ on:
12
+ push:
13
+ branches: [main]
14
+ paths: ['CITATION.cff']
15
+ workflow_dispatch:
16
+
17
+ permissions:
18
+ contents: write
19
+
20
+ jobs:
21
+ release:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ with:
26
+ fetch-depth: 0
27
+
28
+ - name: Read the version from CITATION.cff
29
+ id: read
30
+ run: |
31
+ version=$(sed -n 's/^version:[[:space:]]*"\{0,1\}\([^"[:space:]]*\)"\{0,1\}.*/\1/p' CITATION.cff | head -1)
32
+ if [ -z "$version" ]; then
33
+ echo "CITATION.cff has no version field" >&2
34
+ exit 1
35
+ fi
36
+ echo "version=$version" >> "$GITHUB_OUTPUT"
37
+ if git rev-parse -q --verify "refs/tags/v$version" >/dev/null; then
38
+ echo "tagged=true" >> "$GITHUB_OUTPUT"
39
+ echo "v$version already exists; nothing to do"
40
+ else
41
+ echo "tagged=false" >> "$GITHUB_OUTPUT"
42
+ fi
43
+
44
+ - name: Tag and publish the release
45
+ if: steps.read.outputs.tagged == 'false'
46
+ env:
47
+ GH_TOKEN: ${{ github.token }}
48
+ VERSION: ${{ steps.read.outputs.version }}
49
+ REPO_NAME: ${{ github.event.repository.name }}
50
+ run: |
51
+ git config user.name "github-actions[bot]"
52
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53
+ git tag -a "v$VERSION" -m "$REPO_NAME $VERSION"
54
+ git push origin "v$VERSION"
55
+ gh release create "v$VERSION" --verify-tag --latest --generate-notes --title "$REPO_NAME $VERSION"
56
+ echo "released v$VERSION; Zenodo archives it from the release webhook" >> "$GITHUB_STEP_SUMMARY"