Skip to content

Commit 5b7400c

Browse files
committed
feat: modify workflow to allow custom tagging
1 parent 231388b commit 5b7400c

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Diff for: .github/workflows/release-canary.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,36 @@ on:
44
pull_request:
55
types:
66
- labeled
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Branch to build and release'
11+
required: true
12+
default: 'main'
13+
release_name:
14+
description: 'Release name to publish to npm'
15+
required: true
16+
default: 'experimental'
717

818
jobs:
919
publish:
10-
if: ${{ github.event.label.name == 'build' }}
1120
runs-on: ubuntu-latest
1221
steps:
22+
- name: Validate label name
23+
if: ${{ github.event_name == 'pull_request' && github.event.label.name == 'build' }}
24+
run: echo "Label is 'build', proceeding with the workflow."
25+
26+
- name: Check for open pull request
27+
if: ${{ github.event_name == 'workflow_dispatch' }}
28+
id: check_pr
29+
run: |
30+
PR_DATA=$(gh pr list --state open --head ${{ inputs.branch }} --json number --jq '.[0]')
31+
if [ -z "$PR_DATA" ]; then
32+
echo "No open pull request found for branch ${{ inputs.branch }}."
33+
exit 1
34+
fi
35+
echo "PR_NUMBER=$(echo $PR_DATA | jq -r '.number')" >> $GITHUB_ENV
36+
1337
- uses: actions/checkout@v3
1438
with:
1539
ref: ${{ github.event.pull_request.head.sha }}
@@ -20,7 +44,7 @@ jobs:
2044
registry-url: 'https://registry.npmjs.org'
2145
# Ensure that the README is published with the package
2246
- run: rm -f packages/cli/README.md && cp README.md packages/cli
23-
- run: echo "PR_VERSION=0.0.0-pr.${{github.event.pull_request.number}}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
47+
- run: echo "PR_VERSION=${{ github.event_name == 'workflow_dispatch' && inputs.release_name || '0.0.0-pr.${{github.event.pull_request.number}}'.$(git rev-parse --short HEAD)}}" >> $GITHUB_ENV
2448
- run: npm ci
2549
- run: npm version ${{ env.PR_VERSION }} --workspace packages/cli
2650
- run: npm publish --workspace packages/cli --tag experimental

0 commit comments

Comments
 (0)