generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 56
103 lines (85 loc) · 3.3 KB
/
release.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Release
on:
push:
branches:
- main
# forcing release because of the issue documented here:
# https://github.com/TBD54566975/web5-js/pull/517
- release-1d59f714
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
initiate_api_release:
description: "Initiate @web5/api release"
required: false
default: false
type: boolean
# Triggered when a PR is labeled/unlabeled with `api-release`
pull_request_target:
types: [labeled, unlabeled]
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
# if not a fork, and its a pr label event, check if the head ref is a release branch
if: github.repository == 'TBD54566975/web5-js' && (github.event_name != 'pull_request_target' || (contains(github.event.action, 'labeled') && startsWith(github.event.pull_request.head.ref, 'changeset')))
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
id-token: write # necessary for NPM provenance
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
ref: main
# https://cashapp.github.io/hermit/usage/ci/
- name: Init Hermit
uses: cashapp/activate-hermit@31ce88b17a84941bb1b782f1b7b317856addf286 # v1.1.0
with:
cache: "true"
- name: Store NPM Registry Settings to .npmrc
run: |
echo -e "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" > ~/.npmrc
- name: Verify NPM token is authenticated with NPMjs.com
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm whoami
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build all workspace packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --recursive --stream build
- name: Check @web5/api Release Flow
id: check_api_release
run: scripts/changesets-api-release-check.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KICK_API_RELEASE: ${{ github.event.inputs.initiate_api_release || '' }}
# forcing release because of the issue documented here:
# https://github.com/TBD54566975/web5-js/pull/517
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7
id: changesets
if: steps.check_api_release.outputs.skip_release != 'true'
with:
publish: pnpm changeset publish
version: scripts/changesets-version.sh ${{ steps.check_api_release.outputs.release_web5_api || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-docs:
permissions:
contents: write
pages: write
id-token: write
needs: release
name: Publish Docs
if: ${{ needs.release.outputs.published == 'true' }}
uses: ./.github/workflows/docs-publish.yml