-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (55 loc) · 1.9 KB
/
beta-release-on-label.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Publish Beta Package
# This workflow is triggered on a label being added to a PR, and will publish a beta version of the bundle to npm
# Use `pnpm changeset add` to add a new change
# This action will release the changeset as a pre-release, and add a comment to the PR with the version number
on:
pull_request:
types: [labeled]
permissions: write-all
jobs:
has-permission:
name: Check permissions
runs-on: ubuntu-latest
steps:
- name: 'Check if user has admin access'
uses: 'lannonbr/repo-permission-check-action@2.0.2'
with:
permission: 'admin'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
name: '@guardian/commercial'
runs-on: ubuntu-latest
needs: has-permission
if: github.event.label.name == '[beta] @guardian/commercial'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node
uses: ./.github/actions/setup-node-env
- name: Build package
run: pnpm build
- name: Version
run: pnpm changeset version --snapshot beta
- name: Create Release
uses: changesets/action@v1
id: changeset
with:
publish: pnpm changeset publish --tag beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const publishedPackages = ${{ steps.changeset.outputs.publishedPackages }};
const version = publishedPackages[0].version;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 ${version} published to npm as a beta release`
})