-
Notifications
You must be signed in to change notification settings - Fork 22
172 lines (152 loc) · 5.43 KB
/
release.yml
File metadata and controls
172 lines (152 loc) · 5.43 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: 'Release'
on:
push:
branches:
- master
issue_comment:
types: [created]
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
node-version: '24.x'
snapshot-release-tag: pr${{ github.event.issue.number }}-run${{ github.run_number }}-${{ github.run_attempt }}
jobs:
release:
name: Release
if: github.event.comment == ''
runs-on: ubuntu-24.04
permissions:
id-token: write # allows ODIC publishing
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
cache: yarn
cache-dependency-path: '**/yarn.lock'
- run: yarn install --prefer-offline
- name: Create Release Pull Request or Publish to NPM
id: changesets
uses: changesets/[email protected]
with:
publish: yarn release
commit: 'chore(release): update packages versions'
title: 'Upcoming Release Changes'
env:
GITHUB_TOKEN: ${{ env.github-token }}
release-snapshot-check:
if: github.event.comment != ''
runs-on: ubuntu-24.04
permissions:
pull-requests: write
outputs:
triggered: ${{ steps.check.outputs.triggered }}
steps:
- name: Acknowledge deployment request to commenter
id: check
uses: khan/[email protected]
with:
trigger: '/release-snapshot'
reaction: rocket
env:
GITHUB_TOKEN: ${{ env.github-token }}
- name: Validate user
if: ${{ steps.check.outputs.triggered == 'true' }}
run: |
if [[ "${AUTHOR_ASSOCIATION}" != 'OWNER' ]]
then
echo "User authorization failed"
exit 1
else
echo "User authorization successful"
exit 0
fi
env:
AUTHOR_ASSOCIATION: ${{ github.event.comment.author_association }}
- name: Report failure
if: failure()
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
body: '❌ No permission to release snapshot'
env:
GITHUB_TOKEN: ${{ env.github-token }}
release-snapshot:
runs-on: ubuntu-24.04
needs: release-snapshot-check
permissions:
id-token: write # allows ODIC publishing
contents: read
pull-requests: write # allows posting a message to the PR about success/error
if: needs.release-snapshot-check.outputs.triggered == 'true'
steps:
- name: Get Pull Request ref
id: get_pull_request_ref
uses: octokit/[email protected]
with:
route: GET /repos/{owner}/{repo}/pulls/{issue_number}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ env.github-token }}
- uses: actions/checkout@v4
with:
persist-credentials: true
repository: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn
cache-dependency-path: '**/yarn.lock'
- run: yarn install --prefer-offline
- name: Deploy snapshot
run: |
yarn changeset version --snapshot $RELEASE_TAG
yarn nx run-many --target=build
yarn changeset publish --tag alpha --no-git-tag
env:
GITHUB_TOKEN: ${{ env.github-token }}
RELEASE_TAG: ${{ env.snapshot-release-tag }}
- name: Get snapshot versions
id: get_snapshot_versions
run: |
PACKAGES=(
"@eddeee888/gcg-operation-location-migration"
"@eddeee888/gcg-server-config"
"@eddeee888/gcg-typescript-resolver-files"
)
echo "versions<<EOF" >> $GITHUB_OUTPUT
for pkg in "${PACKAGES[@]}"; do
version=$(npm view "$pkg" dist-tags.alpha)
echo "- \`$pkg@$version\`"
done
echo "EOF" >> $GITHUB_OUTPUT
- name: Report success
if: success()
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
body: '✅ Successfully published package/s:\n ```${{ steps.get_snapshot_versions.outputs.versions }}```'
env:
GITHUB_TOKEN: ${{ env.github-token }}
- name: Report failure
if: failure()
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
body: '❌ Failed to publish package/s with tag `${{ env.snapshot-release-tag }}`'
env:
GITHUB_TOKEN: ${{ env.github-token }}