From b8e04ba06f0d5890a58dbe8b5dea050315eabde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constan=C3=A7a=20Manteigas?= <113898685+constanca-m@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:55:53 +0200 Subject: [PATCH] [Github workflow] Add new tag on version.py update (#685) * Add release workflow --- .github/workflows/changelog.yml | 37 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..527cb043 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..5bd2ac54 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 + })