Skip to content

Commit

Permalink
Adding release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-murray committed Jan 23, 2024
1 parent 8e6e39a commit 6ed65ae
Showing 1 changed file with 126 additions and 0 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Release

run-name: Release ${{ inputs.version }}

on:
workflow_dispatch:
inputs:
version:
type: string
required: true

jobs:
build_and_test:
name: Build and test

runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Build and Test
run: |
npm ci
npm run test --if-present
npm run build --if-present
npm run build-exe --if-present
# - name: Check that build is clean
# run: |
# git diff --exit-code


validate_version:
name: Validate version number
runs-on: ubuntu-22.04

steps:
- name: Process version number as SemVer
id: semver
uses: peter-murray/semver-data-action@v1
with:
version: ${{ inputs.version }}


release:
name: Release

needs:
- validate_version
- build_and_test

runs-on: ubuntu-22.04

steps:
- name: Process version number as SemVer
id: semver
uses: peter-murray/semver-data-action@v1
with:
version: ${{ inputs.version }}

- name: Checkout
uses: actions/checkout@v4

- name: Set git user
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Version application
run: |
npm version ${{ steps.semver.outputs.semver }}
- name: Build
run: |
npm ci
npm run build --if-present
npm run build-exe --if-present
- name: Check that build is clean
id: clean_build
continue-on-error: true
run: |
git diff --exit-code
- name: Update release
if: steps.clean_build.outcome == 'failure'
run: |
git add .
git commit -m "chore: Updating release files"
- name: Update tags
if: steps.semver.outputs.isPreRelease == 'false'
run: |
git tag "v${{ steps.semver.outputs.semver }}" --force
git tag "v${{ steps.semver.outputs.major }}" --force
git tag "v${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}" --force
git tag "v${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}.${{ steps.semver.outputs.patch }}" --force
git push origin ${{ github.ref_name }}
git push origin --tags --force
- name: Attach CLI artifacts
uses: actions/upload-artifact@v3
with:
name: cli
path: cli

- name: Create release
uses: ncipollo/release-action@v1.13.0
with:
artifacts: cli/*
prerelease: ${{ steps.semver.outputs.isPreRelease }}
tag: v${{ steps.semver.outputs.semver }}

0 comments on commit 6ed65ae

Please sign in to comment.