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

feat: create git workflow for release tagging and generate the release note #199

Merged
merged 9 commits into from
Jul 5, 2024
72 changes: 72 additions & 0 deletions .github/workflows/release-tagging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release Tagging

on:
push:
branches:
- main

jobs:
tagging:
runs-on: ubuntu-latest
env:
EXCLUDED_PACKAGE_OA_RENDERERS: '!./packages/vckit-oa-renderers/'
EXCLUDED_PACKAGE_CREDENTIAL_OA: '!./packages/credential-oa/'
EXCLUDED_PACKAGE_EXPLORER: '!./packages/demo-explorer/'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install pnpm
run: npm i pnpm --global

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
ducpm511 marked this conversation as resolved.
Show resolved Hide resolved

- name: Get version from package.json
id: get_version
run: |
version=$(jq -r '.version // empty' < package.json)
if [ -z "$version" ]; then
echo "No valid version found in package.json."
exit 1
fi
echo "::set-output name=version::$version"

- name: Check if tag already exists
id: check_tag
run: |
version=${{ steps.get_version.outputs.version }}
if git rev-parse "v$version" >/dev/null 2>&1; then
echo "Tag v$version already exists."
echo "::set-output name=exists::true"
exit 0
else
echo "::set-output name=exists::false"
fi

- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
git push origin "v${{ steps.get_version.outputs.version }}"

- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ steps.get_version.outputs.version }}"
release_name: "Release ${{ steps.get_version.outputs.version }}"
body: "Automatically generated release notes for version ${{ steps.get_version.outputs.version }}"
draft: false
prerelease: false

Loading