Write version number and tag #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Write version number and tag" | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: "Target branch" | |
required: true | |
type: string | |
version: | |
description: "New version number" | |
required: true | |
type: string | |
jobs: | |
set-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show input parameters | |
shell: bash -l {0} | |
run: | | |
echo "${{ inputs.ref }}" | |
echo "${{ inputs.version }}" | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref }} | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: "Update version.py" | |
shell: bash -l {0} | |
run: | | |
echo "__version__ = \"${{ inputs.version }}\"" > euphonic/version.py | |
cat euphonic/version.py | |
- name: "Update CITATION.cff" | |
shell: bash -l {0} | |
run: | | |
sed -i "s/^version:\ .*/version: ${{ inputs.version }}/" CITATION.cff | |
sed -i "s/^date-released:\ .*/date-released: $(date -I)/" CITATION.cff | |
- name: "Create commit" | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add euphonic/version.py CITATION.cff | |
if git diff --cached --quiet | |
then | |
echo "No files were changed, skipping commit" | |
else | |
git commit -m "Set version number" | |
fi | |
- name: "Tag new commit" | |
shell: bash -l {0} | |
run: | | |
git tag ${{ inputs.version }} | |
- name: "Show updated log" | |
run: | | |
git log --pretty=oneline --abbrev-commit --decorate | head -n 5 | |
git diff HEAD^ | |
- name: "Push commit to branch" | |
shell: bash -l {0} | |
run: | | |
# Verify that ref is a branch (as opposed to a tag or hash) | |
git show-ref --verify "refs/heads/${{ inputs.ref }}" | |
git push origin ${{ inputs.ref }} | |
git push origin tag ${{ inputs.version }} |