From 28291924ae334545897492608919d700ae035247 Mon Sep 17 00:00:00 2001 From: Maija Lintunokka Date: Wed, 30 Oct 2024 15:44:32 +0200 Subject: [PATCH 1/2] feat: borrow the createRelease workflow from DS --- .github/pull_request_template.md | 30 ++++++++++++++++ .github/workflows/createRelease.yml | 54 ++++++++++++++++++++++++++++ .github/workflows/scripts/release.sh | 28 +++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/createRelease.yml create mode 100755 .github/workflows/scripts/release.sh diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..7ec6133 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,30 @@ +## Description + + + +## Related Jira ticket + + + + + + +## Documentation + + + +## Checklist + + + +- [ ] Pull Request is properly described. +- [ ] The corresponding Jira ticket is updated. +- [ ] I have requested a review from at least one reviewer. +- [ ] The changes are tested +- [ ] I have verified my UX changes with a designer +- [ ] I have checked my code for any possible security vulnerabilities + +## Screenshots + + + diff --git a/.github/workflows/createRelease.yml b/.github/workflows/createRelease.yml new file mode 100644 index 0000000..a98385e --- /dev/null +++ b/.github/workflows/createRelease.yml @@ -0,0 +1,54 @@ +name: Create Release + +on: + workflow_dispatch: + inputs: + mode: + type: choice + description: "Release mode" + required: true + default: patch + options: + - patch + - minor + - major + +jobs: + github-release: + runs-on: + group: Personalisation + labels: [self-hosted, linux, x64] + steps: + - name: Checkout current branch + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref || github.ref_name }} + token: ${{ secrets.RELEASE_PAT_TOKEN }} + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Create tag + id: tag-changelog + shell: bash + working-directory: ${{ github.workspace }}/.github/workflows + env: + mode: ${{ inputs.mode }} + workspace: ${{ github.workspace }} + run: ./scripts/release.sh + + - name: Create Github Release + if: success() && steps.tag-changelog.outputs.new_version != '' + env: + tag: ${{ steps.tag-changelog.outputs.new_version }} + GH_TOKEN: ${{ secrets.RELEASE_PAT_TOKEN }} + shell: bash + run: | + gh release create "$tag" \ + --repo "$GITHUB_REPOSITORY" \ + --title "${GITHUB_REPOSITORY#*/} ${tag#v}" \ + --generate-notes \ + --verify-tag diff --git a/.github/workflows/scripts/release.sh b/.github/workflows/scripts/release.sh new file mode 100755 index 0000000..c5f62f1 --- /dev/null +++ b/.github/workflows/scripts/release.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Setup git globals +echo 'Config git globals' +git config --global user.name "nosto-cicd" +git config --global user.email "127484979+nosto-cicd@users.noreply.github.com" + +# Fetching current and new version +echo 'Fetching current and the next version' +current_version="$(git tag --list --sort=-creatordate | head -n 1)" +new_version="$(npm --no-git-tag-version version $mode | cut -c2-)" +echo "current_version=${current_version}" +echo "new_version=${new_version}" + +# Creating git tag +if [ ! -z "$new_version" ] +then + echo 'Creating git tag' + # needed to be committed after the version update by npm version command + git add $workspace/package*.json + git commit -m 'Bump version' + git tag -a $new_version -m "Tag $new_version for design system" + git push origin master + git push origin $new_version + echo "new_version=${new_version}" >> $GITHUB_OUTPUT +else + echo "Skipping release as new version is invalid: $new_version" +fi \ No newline at end of file From 1f15812ba69ed4d0c11f6a2504578be81b60ef42 Mon Sep 17 00:00:00 2001 From: Maija Lintunokka Date: Wed, 30 Oct 2024 16:16:03 +0200 Subject: [PATCH 2/2] chore: update pull_request_template --- .github/pull_request_template.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7ec6133..50fc03b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -21,7 +21,6 @@ - [ ] The corresponding Jira ticket is updated. - [ ] I have requested a review from at least one reviewer. - [ ] The changes are tested -- [ ] I have verified my UX changes with a designer - [ ] I have checked my code for any possible security vulnerabilities ## Screenshots