Skip to content

Commit

Permalink
Merge pull request #24 from Nosto/feat/releasePipeline2
Browse files Browse the repository at this point in the history
Borrow the createRelease workflow from DS
  • Loading branch information
maijalintunokka authored Oct 31, 2024
2 parents bb7d0e7 + 1f15812 commit b1fed24
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Description

<!--- Describe your changes -->

## Related Jira ticket

<!--- Is there a Jira ticket for this change, if not - should there be? -->
<!--- If working on a new feature or change, please discuss it in an ticket first -->
<!--- If fixing a bug, there should be an ticket describing it with steps to reproduce -->
<!--- Please link to the ticket here: -->

## Documentation

<!--- Is the change documented or should it be?, link the relevant wiki/confluence page here. -->

## Checklist

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->

- [ ] 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 checked my code for any possible security vulnerabilities

## Screenshots

<!--- If there is a visual element to the PR please share screenshots -->
<!--- Remember the saying "one picture says the same as a 1000 words". -->
54 changes: 54 additions & 0 deletions .github/workflows/createRelease.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"

# 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

0 comments on commit b1fed24

Please sign in to comment.