-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 2.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
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
# Get GitHub token via the CT Changesets App
- name: Generate GitHub token (via CT Changesets App)
id: generate_github_token
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.CT_CHANGESETS_APP_ID }}
private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }}
- name: Checkout
uses: actions/checkout@v4
with:
# Pass a personal access token (using our `ct-changesets` app) to be able to trigger other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
token: ${{ steps.generate_github_token.outputs.token }}
- name: Install pnpm
uses: pnpm/action-setup@v4.0.0
with:
run_install: false
- name: Setup Node (uses version in .nvmrc)
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
email=npmjs@commercetools.com
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Building packages
run: pnpm build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1.4.7
with:
commit: 'ci(changesets): version packages'
publish: pnpm changeset publish
version: pnpm changeset:version-and-format
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
# Publish canary releases only if the packages weren't published already
- name: Publishing canary releases to npm registry
if: steps.changesets.outputs.published != 'true'
run: |
git checkout main
pnpm changeset version --snapshot canary
pnpm changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}