Skip to content

Commit

Permalink
Task: Automatically update CodeMeta upon release #1276
Browse files Browse the repository at this point in the history
  • Loading branch information
OlawumiSalaam committed Oct 3, 2024
1 parent c6b18a7 commit 04d293d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Single workflow to increment ersilia version in pyproject.toml,
# Single workflow to increment Ersilia version in pyproject.toml,
# tag and push the commit to the repository, release to GitHub, PyPI, Conda, and DockerHub

name: Ersilia Release

on:
workflow_dispatch: # run manually
schedule:
- cron: ' 0 3 1 * *' # run at 3:00 AM on the first day of the month
- cron: '0 3 1 * *' # run at 3:00 AM on the first day of the month

jobs:
version:
Expand All @@ -18,8 +18,8 @@ jobs:
- name: Checkout persist credentials
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v3.5.3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
persist-credentials: false # ensures use of personal token instead of GITHUB_TOKEN
fetch-depth: 0 # fetches all history for tagging

- name: Increment package version
id: version
Expand All @@ -33,12 +33,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# git config http.sslVerify false
# repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git config --local user.email "ersilia-bot@users.noreply.github.com"
git config --local user.name "ersilia-bot"
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "v${{ steps.version.outputs.VERSION }}"
# git push "${repo}" origin "v${{ steps.version.outputs.VERSION }}"
git push origin "v${{ steps.version.outputs.VERSION }}"
- name: Update version in CITATION.cff
id: update-citation
Expand All @@ -57,12 +55,22 @@ jobs:
yaml.dump(citation, file, default_flow_style=False, sort_keys=False)
"
- name: Commit and push changes done to the static version file and pyproject.toml
- name: Update version in codemeta.json
id: update-codemeta
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
# Ensure jq is installed
sudo apt-get install -y jq
# Update the version in codemeta.json
jq '.version = env.VERSION' codemeta.json > codemeta_tmp.json && mv codemeta_tmp.json codemeta.json
- name: Commit and push changes to CITATION.cff and codemeta.json
uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # pin@v1.5
with:
author_name: "ersilia-bot"
author_email: "ersilia-bot@users.noreply.github.com"
message: "update version [skip ci]"
message: "Update version in CITATION.cff and codemeta.json [skip ci]"
repository: "ersilia-os/${{ github.event.repository.name }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
amend: true
Expand All @@ -80,13 +88,10 @@ jobs:
- name: Create GitHub release
id: gh_release
run: |
# Get the version file that we updated in the previous job
wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/ersilia/_static_version.py
month=$(date +'%B')
year=$(date +'%Y')
title="$month $year"
version=`sed -n 's/.*version = "\([^"]*\)".*/\1/p' _static_version.py`
version=${{ needs.version.outputs.VERSION }}
git fetch --tags
gh release create "v$version" --title "$title" --generate-notes
Expand All @@ -102,7 +107,6 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # pin@v5.2.0
with:
python-version: '3.8'
# cache: 'pip' # caching pip dependencies

- name: Python Poetry Action
uses: abatilo/actions-poetry@v3.0.0
Expand All @@ -114,6 +118,4 @@ jobs:
run: |
git pull origin master
poetry config -- http-basic.pypi $PYPI_USERNAME $PYPI_PASSWORD
poetry --build publish
poetry --build publish

0 comments on commit 04d293d

Please sign in to comment.