-
Notifications
You must be signed in to change notification settings - Fork 48
177 lines (150 loc) · 5.86 KB
/
rc-publish-test.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
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
173
174
175
176
177
name: Publish rc test
on:
push:
branches:
- fix-bugs
# Declare default permissions as read only.
permissions: read-all
jobs:
check_author:
runs-on: ubuntu-22.04
outputs:
latest_commit_author: ${{ steps.commit.outputs.author }}
commit_message: ${{ steps.commit.outputs.message }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: Checkout Repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Install yq
run: |
sudo apt-get update &&\
sudo apt-get install wget -y &&\
sudo wget https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -O /usr/bin/yq &&\
sudo chmod +x /usr/bin/yq
- name: Get last commit details
id: commit
run: |
COMMIT_SHA="$(git rev-parse HEAD)"
AUTHOR=$(git show -s --format='%an' $COMMIT_SHA)
MESSAGE=$(git show -s --format='%s' $COMMIT_SHA)
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
echo "message=$MESSAGE" >> $GITHUB_OUTPUT
echo "Author of the commit is $AUTHOR"
echo "Message of the commit is $MESSAGE"
prepare:
needs: check_author
runs-on: ubuntu-22.04
if: ${{ needs.check_author.outputs.latest_commit_author == 'github-actions[bot]' && contains(needs.check_author.outputs.commit_message, 'rc') }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: Checkout Repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
# Deterministic Build & tests
provenance:
permissions:
id-token: write
contents: read
actions: read
needs: prepare
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
run-scripts: "install-deps, style, nx-build-skip-cache, nx-test-skip-cache"
node-version: "16.20.0"
tag:
name: Tag RC candidate for all packages
permissions:
id-token: write
contents: write
actions: read
runs-on: ubuntu-22.04
needs: provenance
outputs:
rc_version: ${{ steps.get_version.outputs.rc_version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.SAI_PAT }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
with:
gpg_private_key: ${{ secrets.SVC_GPG_KEY }}
passphrase: ${{ secrets.SVC_GPG_PASSPHRASE }}
git_config_global: true
git_tag_gpgsign: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Use node@16
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: 16.20.0
- name: Create temp dir
id: temp-dir
run: |
set -euo pipefail
temp_dir=$(mktemp -d)
echo "path=${temp_dir}" >>"${GITHUB_OUTPUT}"
- name: Download tarball
uses: slsa-framework/slsa-github-generator/.github/actions/secure-download-artifact@934435652996c02a6317092984312602dfaf2a21 # main
with:
name: ${{ needs.provenance.outputs.package-download-name }}
path: "${{ steps.temp-dir.outputs.path }}/${{ needs.provenance.outputs.package-name }}"
sha256: ${{ needs.provenance.outputs.package-download-sha256 }}
- name: Download provenance
uses: slsa-framework/slsa-github-generator/actions/nodejs/secure-attestations-download@0779f7bec68e2bf54a7b0a32bf4763f25ab29702 # v1.6.0
with:
name: ${{ needs.provenance.outputs.provenance-download-name }}
path: "${{ steps.temp-dir.outputs.path }}"
sha256: ${{ needs.provenance.outputs.provenance-download-sha256 }}
- name: Authenticate NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
echo "@openzeppelin:registry https://registry.npmjs.org" >> ~/.npmrc
- name: Enable NPM PROVENANCE
run: echo "NPM_CONFIG_PROVENANCE=true" >> $GITHUB_ENV
- name: Get version info
id: get_version
run: |
TAG_NAME=$(node -p "require('./lerna.json').version")
echo "rc_version=v$TAG_NAME" >> $GITHUB_OUTPUT
- name: Unpack the zipped artifact and publish
run: |
set -euo pipefail
cd "${{ steps.temp-dir.outputs.path }}"
tar -xzvf "${{ needs.provenance.outputs.package-name }}"
cd package/; git init
git add .
git commit -m "Add the untracked files"
tag_ref=${{ steps.get_version.outputs.rc_version }}
tag_version=${tag_ref#refs/tags/v}
lerna_options="--no-git-tag-version --no-push --ignore-scripts --yes --exact --no-changelog"
cd ../../
- name: Create and push tag
run: |
git tag -a ${{ steps.get_version.outputs.rc_version }} -m "${{ steps.get_version.outputs.rc_version }}"
git push origin ${{ steps.get_version.outputs.rc_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-release:
permissions:
contents: write
name: Create Release
needs: tag
uses: ./.github/workflows/release.yml
with:
tag: ${{ needs.tag.outputs.rc_version }}
prerelease: true