Skip to content

Commit 612482e

Browse files
authored
Merge pull request #288 from streamflow-finance/feat/allow-manual-alphas
Allow manual alpha releases
2 parents cdd1764 + 529a448 commit 612482e

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

.github/workflows/gh-alpha-release.yml

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,64 @@ name: Alpha Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_number:
7+
description: 'PR number (for manual runs)'
8+
required: true
59
pull_request:
610
branches:
711
- master
812

913
jobs:
10-
check-commit-message:
14+
resolve-alpha:
1115
runs-on: ubuntu-latest
1216
outputs:
13-
skip_alpha: ${{ steps.check_commit.outputs.skip_alpha }}
17+
alpha_version: ${{ steps.set_alpha_version.outputs.alpha_version }}
1418
steps:
1519
- name: Checkout code
1620
uses: actions/checkout@v4
1721
with:
18-
ref: ${{ github.event.pull_request.head.ref }}
19-
- name: Check PR head commit message
20-
id: check_commit
22+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
23+
- name: Resolve alpha version
24+
id: set_alpha_version
2125
run: |
22-
message=$(git log -1 --pretty=%B | head -n 1)
23-
echo "Checking commit message: \"$message\""
24-
if [[ "$message" == *'[skip alpha]'* ]]; then
25-
echo "Found '[skip alpha]'. Setting skip_alpha=true"
26-
echo "skip_alpha=true" >> $GITHUB_OUTPUT
27-
else
28-
echo "Did not find '[skip alpha]'. Setting skip_alpha=false"
29-
echo "skip_alpha=false" >> $GITHUB_OUTPUT
26+
BASE_VERSION=$(node -p 'require("./lerna.json").version')
27+
SHORT_SHA=$(git rev-parse --short HEAD)
28+
ALPHA_VERSION=""
29+
if [ "${{ github.event_name }}" = "pull_request" ]; then
30+
BRANCH="${{ github.head_ref }}"
31+
if [[ "$BRANCH" == alpha/* ]]; then
32+
message=$(git log -1 --pretty=%B | head -n 1)
33+
if [[ "$message" != *'[skip alpha]'* ]]; then
34+
PR_NUMBER="${{ github.event.pull_request.number }}"
35+
ALPHA_VERSION="${BASE_VERSION}-alpha.p${PR_NUMBER}.${SHORT_SHA}"
36+
fi
37+
fi
38+
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
39+
PR_NUMBER="${{ github.event.inputs.pr_number }}"
40+
if [ -n "$PR_NUMBER" ]; then
41+
ALPHA_VERSION="${BASE_VERSION}-alpha.p${PR_NUMBER}.${SHORT_SHA}"
42+
fi
3043
fi
44+
echo "alpha_version=$ALPHA_VERSION" >> $GITHUB_OUTPUT
45+
echo "ALPHA_VERSION=$ALPHA_VERSION"
46+
3147
tests:
32-
if: startsWith(github.head_ref, 'alpha/') && needs.check-commit-message.outputs.skip_alpha != 'true'
33-
needs: check-commit-message
48+
if: needs.resolve-alpha.outputs.alpha_version != ''
49+
needs: resolve-alpha
3450
uses: ./.github/workflows/version-tests.yml
3551

3652
all-tests-pass:
37-
if: startsWith(github.head_ref, 'alpha/') && needs.check-commit-message.outputs.skip_alpha != 'true'
53+
if: needs.resolve-alpha.outputs.alpha_version != ''
3854
runs-on: ubuntu-latest
39-
needs: [tests, check-commit-message]
55+
needs: [tests, resolve-alpha]
4056
steps:
4157
- run: echo "All tests completed"
4258

4359
publish-alpha:
44-
if: startsWith(github.head_ref, 'alpha/') && needs.check-commit-message.outputs.skip_alpha != 'true'
45-
needs: [all-tests-pass, check-commit-message]
60+
if: needs.resolve-alpha.outputs.alpha_version != ''
4661
runs-on: ubuntu-latest
62+
needs: [all-tests-pass, resolve-alpha]
4763
steps:
4864
- uses: actions/checkout@v4
4965
- uses: pnpm/action-setup@v4
@@ -57,24 +73,16 @@ jobs:
5773
registry-url: https://registry.npmjs.org/
5874
- name: Install dependencies
5975
run: pnpm install
60-
- name: Set Alpha Version
61-
id: set_alpha_version
62-
run: |
63-
BASE_VERSION=$(node -p 'require("./lerna.json").version')
64-
SHORT_SHA=$(git rev-parse --short HEAD)
65-
PR_NUMBER=${{ github.event.pull_request.number }}
66-
ALPHA_VERSION="${BASE_VERSION}-alpha.p${PR_NUMBER}.${SHORT_SHA}"
67-
echo "ALPHA_VERSION=$ALPHA_VERSION" >> $GITHUB_ENV
6876
- name: Version all packages
69-
run: pnpm version-all ${{ env.ALPHA_VERSION }} -y
77+
run: pnpm version-all ${{ needs.resolve-alpha.outputs.alpha_version }} -y
7078
- name: Git status
7179
run: git status
7280
- name: Commit version changes
7381
run: |
7482
git config --global user.name 'github-actions[bot]'
7583
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
7684
git add -A
77-
git commit -m "chore: version bump to ${{ env.ALPHA_VERSION }} [skip ci]" --no-verify || echo "No changes to commit"
85+
git commit -m "chore: version bump to ${{ needs.resolve-alpha.outputs.alpha_version }} [skip ci]" --no-verify || echo "No changes to commit"
7886
- name: Git status after
7987
run: git status
8088
- name: Build packages

0 commit comments

Comments
 (0)