-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathflow-deploy-release-artifact.yaml
More file actions
278 lines (239 loc) · 9.73 KB
/
flow-deploy-release-artifact.yaml
File metadata and controls
278 lines (239 loc) · 9.73 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
##
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
name: 'Deploy Release Artifact'
on:
workflow_dispatch:
inputs:
dry-run-enabled:
description: 'Perform Dry Run'
type: boolean
required: false
default: false
defaults:
run:
shell: bash
permissions:
id-token: write
checks: write
statuses: write
pull-requests: write
contents: write
issues: write
actions: read
jobs:
prepare-release:
name: Release / Prepare
runs-on: hiero-cli-linux-medium
outputs:
version: ${{ steps.tag.outputs.version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0
- name: Calculate Next Version
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: npx semantic-release --dry-run
- name: Extract Version
id: tag
run: |
[[ "${{ github.event.inputs.dry-run-enabled }}" == true && ! -f VERSION ]] && echo -n "0.0.0-latest" > VERSION
echo "version=$(cat VERSION | tr -d '[:space:]')" >> ${GITHUB_OUTPUT}
safety-checks:
name: Release
uses: ./.github/workflows/zxc-compile-code.yaml
with:
custom-job-label: 'Safety Checks'
enable-unit-tests: true
enable-integration-tests: true
enable-code-style-check: true
secrets:
integration-tests-network: ${{ secrets.INTEGRATION_TESTS_NETWORK }}
integration-tests-operator-id: ${{ secrets.INTEGRATION_TESTS_OPERATOR_ID }}
integration-tests-operator-key: ${{ secrets.INTEGRATION_TESTS_OPERATOR_KEY }}
create-github-release:
name: Github / Release
runs-on: hiero-cli-linux-medium
needs:
- prepare-release
- safety-checks
outputs:
npm-artifact-name: ${{ steps.set-publish-data.outputs.artifact-name }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0
- name: Install GnuPG Tools
run: |
if ! command -v gpg2 >/dev/null 2>&1; then
echo "::group::Updating APT Repository Indices"
sudo apt update
echo "::endgroup::"
echo "::group::Installing GnuPG Tools"
sudo apt install -y gnupg2
echo "::endgroup::"
fi
- name: Import GPG key
id: gpg_key
uses: step-security/ghaction-import-gpg@69c854a83c7f79463f8bdf46772ab09826c560cd # v6.3.1
with:
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: false
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
- name: Setup JQ
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
with:
version: 1.7
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@c32bf10843e4071112c4ea3abf622d3b27cd8c17 # v4.7.0
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Show JFrog Config
run: jfrog config show
- name: Verify JFrog Connectivity
run: jfrog rt ping
- name: Setup JFrog NPM Repository
run: |
jf npmc --server-id-resolve setup-jfrog-cli-server --server-id-deploy setup-jfrog-cli-server --repo-resolve hedera-cli-npm-release --repo-deploy hedera-cli-npm-release
echo "::group::JFrog NPM Repository Configuration"
cat .jfrog/projects/npm.yaml
echo "::endgroup::"
- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0
- name: Install Dependencies
run: jf npm ci
- name: Compile Code
run: npm run build
- name: GH Auth Status (with ENV)
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: gh auth status
- name: Publish Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
run:
npx semantic-release
- name: Update Version for Dry Run
if: ${{ github.event.inputs.dry-run-enabled == 'true' }}
run: |
npm version ${{ needs.prepare-release.outputs.version }} --no-git-tag-version
- name: Set Publish Data
id: set-publish-data
run: |
VERSION=$(jq -r '.version' './package.json')
CLI_NPM_PACKAGE_NAME="hiero-ledger-hiero-cli-${VERSION}.tgz"
echo "artifact-name=${CLI_NPM_PACKAGE_NAME}" >> $GITHUB_OUTPUT
# Needed since semantic release dry-run won't pack the tarball
- name: Pack for Dry Run
if: ${{ github.event.inputs.dry-run-enabled == 'true' }}
run: |
npm pack --pack-destination ./dist
- name: Verify Release
run: |
echo "Expected package name: ${{ steps.set-publish-data.outputs.artifact-name }}"
echo "Dist dir files:"
ls -la ./dist
# # Upload the artifact
# - name: Upload Hiero CLI Package Artifact
# uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
# with:
# name: cli-npm-package
# path: ./dist/${{ steps.set-publish-data.outputs.artifact-name }}
# if-no-files-found: error
# - name: Deploy to JFrog Registry
# if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
# run: jf npm publish
# # Add a publishing job for Hiero CLI to npmjs
# publish-npm-package:
# name: Publish Hiero CLI NPM Package
# runs-on: ubuntu-latest
# needs:
# - create-github-release
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
# with:
# egress-policy: audit
# - name: Checkout Code
# uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
# with:
# fetch-depth: 1
# - name: Setup Node
# uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
# with:
# node-version: 22
# registry-url: 'https://registry.npmjs.org'
# - name: Install NPM latest
# run: npm install -g npm@11.7.0
# - name: Download Hiero CLI NPM Package Artifact
# uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
# with:
# name: cli-npm-package
# - name: Publish Hiero CLI NPM Package
# run: |
# args="--access=public"
# if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
# args="${args} --dry-run"
# fi
# package="${{ needs.create-github-release.outputs.npm-artifact-name }}"
# echo "::group::Publishing package: ${package} with args: ${args}"
# npm publish ${package} ${args}
# echo "::endgroup::"