Skip to content

Commit

Permalink
[Github workflow] Add new tag on version.py update (#685)
Browse files Browse the repository at this point in the history
* Add release workflow
  • Loading branch information
constanca-m authored Apr 17, 2024
1 parent 8561680 commit b8e04ba
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
## Workflow to check CHANGELOG was updated when version gets updated in share/version.py
name: changelog

on:
pull_request:
paths:
- 'share/version.py'

jobs:

changelog:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:

- uses: actions/checkout@v4

- name: Get version number
shell: bash
run: |
VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' share/version.py)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "::notice::ESF version is $VERSION."
- name: Check changelog
shell: bash
run: |
first_line=$(awk 'NR==1' CHANGELOG.md)
if [[ $first_line != *" v${{ env.VERSION }} "* ]]; then
error="CHANGELOG should contain the new version in its first line, like this ' v1.1.1 '."
reminder="Do not forget to add space before and after the version in the CHANGELOG first line."
echo "::error::$error $reminder"
exit 1
fi
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
## Workflow to create a new git tag if version.py variable version gets updated
name: release

permissions:
contents: write # write permission is required to create a GitHub release

on:
push:
branches:
- 'main'
paths:
- 'share/version.py'

jobs:

release:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:

- uses: actions/checkout@v4

- name: Get version number
shell: bash
run: |
VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' share/version.py)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "::notice::ESF version is $VERSION."
- name: Create tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/lambda-v' + ${{ env.VERSION }},
sha: context.sha
})

0 comments on commit b8e04ba

Please sign in to comment.