-
Notifications
You must be signed in to change notification settings - Fork 8
216 lines (191 loc) · 7.57 KB
/
flow-deploy-release-artifact.yaml
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
##
# 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
env:
REGISTRY: ghcr.io
defaults:
run:
shell: bash
permissions:
contents: write
packages: write
pages: write
id-token: write
jobs:
prepare-release:
name: Release / Prepare
runs-on: solo-linux-medium
outputs:
version: ${{ steps.tag.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup Node with Retry
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0
with:
action: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with: |
node-version: 20.14.0
cache: npm
attempt_limit: 3
attempt_delay: 5000
- name: Install Semantic Release
run: |
npm install -g [email protected] @semantic-release/[email protected] @semantic-release/[email protected] [email protected]
- name: Calculate Next Version
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_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
ls -al
cat VERSION
- name: Extract Version
id: tag
run: |
cat VERSION
[[ "${{ github.event.inputs.dry-run-enabled }}" == true && ! -f VERSION ]] && echo -n "0.0.0-latest" > VERSION
echo "version=$(cat VERSION | tr -d '[:space:]')" | tee -a ${GITHUB_OUTPUT}
verify-version-output:
name: Verify Version Output
runs-on: solo-linux-medium
needs:
- prepare-release
steps:
- name: Verify version output
env:
VERSION: ${{ needs.prepare-release.outputs.version }}
run: echo "VERSION=${VERSION}"
update-readme:
name: "Update README.md"
uses: ./.github/workflows/flow-update-readme.yaml
needs:
- prepare-release
with:
commit-changes: true
version: ${{ needs.prepare-release.outputs.version }}
secrets:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
GH_ACCESS_GPG_KEY: ${{ secrets.GH_ACCESS_GPG_KEY }}
GH_ACCESS_PASSPHRASE: ${{ secrets.GH_ACCESS_PASSPHRASE }}
create-github-release:
name: Github / Release
runs-on: solo-linux-medium
needs:
- update-readme
steps:
- name: verification and testing
env:
commit: ${{ needs.update-readme.outputs.commit-hash }}
commit2: ${{ needs.update-readme.outputs.commit-hash2 }}
run: |
echo "commit=${commit}"
echo "commit hash=${{ needs.update-readme.outputs.commit-hash }}"
echo "commit2=${commit2}"
echo "commit hash2=${{ needs.update-readme.outputs.commit-hash2 }}"
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0
ref: ${{ needs.update-readme.outputs.commit-hash }}
- 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: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
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 with Retry
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0
with:
action: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with: |
node-version: 20.14.0
cache: npm
attempt_limit: 3
attempt_delay: 5000
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@9fe0f98bd45b19e6e931d457f4e98f8f84461fb5 # v4.4.1
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 solo-npm-release --repo-deploy solo-npm-release
echo "::group::JFrog NPM Repository Configuration"
cat .jfrog/projects/npm.yaml
echo "::endgroup::"
- name: Install Semantic Release
run: |
npm install -g [email protected] @semantic-release/[email protected] @semantic-release/[email protected] [email protected]
- name: Install Dependencies
run: jf npm ci
- name: Setup NPM Authentication
run: |
# create .npmrc file to publish solo to Github NPM registry
rm -f .npmrc || true
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ".npmrc"
echo '@hashgraph:registry=https://registry.npmjs.org/' >> ".npmrc"
- name: Publish Semantic Release
env:
commit: ${{ needs.update-readme.outputs.commit-hash }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
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: Deploy to JFrog Registry
if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
run: jf npm publish