Skip to content

Commit cb7d098

Browse files
authored
feat: add release workflow for manual TEST deployments (#2316)
1 parent e904fda commit cb7d098

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/release.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: 'Release version (e.g., v1.2.3). Leave empty to calculate from semantic commits.'
8+
required: false
9+
type: string
10+
11+
concurrency:
12+
group: ${{ github.workflow }}
13+
cancel-in-progress: true
14+
15+
permissions: {}
16+
17+
jobs:
18+
vars:
19+
name: Set Variables
20+
outputs:
21+
pr: ${{ steps.pr.outputs.pr }}
22+
runs-on: ubuntu-24.04
23+
timeout-minutes: 1
24+
steps:
25+
# Get PR number for the last merged PR
26+
- name: PR Number
27+
id: pr
28+
uses: bcgov/action-get-pr@35514fa1d4765547da319e967b509363598e8b46 # v0.1.0
29+
30+
semantic-release:
31+
runs-on: ubuntu-24.04
32+
needs: [vars]
33+
permissions:
34+
contents: write
35+
outputs:
36+
tag: ${{ steps.set-version.outputs.tag }}
37+
version: ${{ steps.set-version.outputs.version }}
38+
steps:
39+
- uses: actions/checkout@v5
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Set Version from Input
44+
id: version-input
45+
if: ${{ inputs.release != '' }}
46+
run: |
47+
VERSION="${{ inputs.release }}"
48+
# Validate semantic version format: vMAJOR.MINOR.PATCH
49+
# Example: v1.2.3
50+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
51+
echo "Error: Release names must use semantic versioning (e.g., v1.2.3). Got: $VERSION"
52+
exit 1
53+
fi
54+
# Version without 'v' prefix for outputs
55+
VERSION_NUM="${VERSION#v}"
56+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
57+
echo "version=$VERSION_NUM" >> $GITHUB_OUTPUT
58+
59+
- name: Conventional Changelog Update
60+
uses: TriPSs/conventional-changelog-action@67139193614f5b9e8db87da1bd4240922b34d765 # v6
61+
id: changelog
62+
if: ${{ inputs.release == '' }}
63+
continue-on-error: true
64+
with:
65+
github-token: ${{ github.token }}
66+
output-file: 'CHANGELOG.md'
67+
skip-version-file: 'true'
68+
skip-commit: 'true'
69+
skip-on-empty: 'false'
70+
git-push: 'true'
71+
72+
- name: Set Final Version
73+
id: set-version
74+
run: |
75+
if [ "${{ inputs.release }}" != "" ]; then
76+
echo "tag=${{ steps.version-input.outputs.tag }}" >> $GITHUB_OUTPUT
77+
echo "version=${{ steps.version-input.outputs.version }}" >> $GITHUB_OUTPUT
78+
else
79+
echo "tag=${{ steps.changelog.outputs.tag }}" >> $GITHUB_OUTPUT
80+
echo "version=${{ steps.changelog.outputs.version }}" >> $GITHUB_OUTPUT
81+
fi
82+
83+
- name: Create Release
84+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
85+
if: steps.set-version.outputs.tag != ''
86+
continue-on-error: true
87+
env:
88+
GITHUB_TOKEN: ${{ github.token }}
89+
with:
90+
token: ${{ github.token }}
91+
tag_name: ${{ steps.set-version.outputs.tag }}
92+
name: ${{ steps.set-version.outputs.tag }}
93+
generate_release_notes: true
94+
95+
deploys-test:
96+
name: TEST Deploys (${{ needs.vars.outputs.pr }})
97+
needs: [vars, semantic-release]
98+
secrets: inherit
99+
uses: ./.github/workflows/.deploy.yml
100+
with:
101+
environment: test
102+
tag: ${{ needs.vars.outputs.pr }}
103+
target: test

0 commit comments

Comments
 (0)