Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #25

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading