Skip to content

Commit

Permalink
Add release workflow (#457)
Browse files Browse the repository at this point in the history
Signed-off-by: achour94 <[email protected]>
  • Loading branch information
achour94 authored Dec 4, 2024
1 parent b9605fd commit 7b4b3d2
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release

on:
workflow_dispatch:
inputs:
releaseVersion:
description: Release version (vX.X)
required: true
gitReference:
description: SHA of the commit from where to release or branch name
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
name: Generate app token
with:
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }}

- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

- name: Parse release version
run: |
regex="^v([0-9]+)\.([0-9]+)$"
if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]]
then
echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
echo "GITHUB_SHORT_VERSION=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0" >> $GITHUB_ENV
else
echo ERROR: release version should match the format vX.X
exit 1
fi
- name: Check if release already exists
run: |
if git ls-remote --quiet --exit-code origin refs/heads/release-${{ github.event.inputs.releaseVersion }} >/dev/null 2>&1
then
echo "ERROR: Release ${{ github.event.inputs.releaseVersion }} already exists"
exit 1
else
echo "Release ${{ github.event.inputs.releaseVersion }} doesn't exist, it will be performed"
fi
- name: Checkout with new branch
run: |
git checkout -b release-v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} ${{ github.event.inputs.gitReference }}
- name: Create commit and tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Release v${{ env.GITHUB_SHORT_VERSION }}"
git tag v${{ env.GITHUB_SHORT_VERSION }}
git push origin release-v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}
git push origin v${{ env.GITHUB_SHORT_VERSION }}

0 comments on commit 7b4b3d2

Please sign in to comment.