-
Notifications
You must be signed in to change notification settings - Fork 42
185 lines (160 loc) · 5.36 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
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
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.
# GitHub Actions workflow to create releases.
# Releases are published from tags matching "v*.*.*".
name: "Release"
on:
push:
tags: [ "v*.*.*" ]
concurrency:
group: "release-${{ github.ref }}"
cancel-in-progress: true
env:
GO_VERSION: "1.23.x"
PNPM_VERSION: "9.4.x"
GO_LDFLAGS: >-
-X 'github.com/hemilabs/heminetwork/version.Brand=Hemi Labs'
-X github.com/hemilabs/heminetwork/version.PreRelease=
jobs:
# Build and test
test-go:
name: "Test (Go)"
uses: ./.github/workflows/go.yml
# Prepare to release
prepare:
name: "Prepare"
runs-on: "ubuntu-latest"
permissions:
contents: read
outputs:
version: "${{ steps.version.outputs.version }}"
tag: "${{ steps.version.outputs.tag }}"
version_type: "${{ steps.version.outputs.type }}"
steps:
- name: "Determine version type"
id: version
env:
RAW_VERSION: "${{ github.ref_name }}"
# This script determines the version type (stability), e.g.
# 1.0.0 = stable, 1.1.0-rc.1 = unstable, 0.1.0 = unstable
run: |
VERSION=$(echo "$RAW_VERSION" | sed -e 's/^v//')
TAG=$(echo "$RAW_VERSION" | sed -E 's/^([^v])/v\1/g')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
TYPE=unstable
if echo "$VERSION" | grep -Eq '^[1-9][0-9]*\.[0-9]+\.[0-9]+$'; then
TYPE=stable
fi
echo "Detected that $TAG is $TYPE"
echo "type=$TYPE" >> "$GITHUB_OUTPUT"
# Publish NPM packages
npm:
name: "npm"
runs-on: "ubuntu-latest"
needs: [ "prepare" ]
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true
- name: "Setup pnpm ${{ env.PNPM_VERSION }}"
uses: pnpm/action-setup@v4
with:
version: "${{ env.PNPM_VERSION }}"
- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version-file: "web/.nvmrc"
check-latest: true
cache: "pnpm"
cache-dependency-path: "web/**/pnpm-lock.yaml"
registry-url: "https://registry.npmjs.org"
- name: "Install dependencies"
working-directory: "web/"
run: pnpm install --frozen-lockfile
- name: "Install Go dependencies"
working-directory: "web/"
run: make deps
- name: "Set package.json versions"
working-directory: "web/"
env:
VERSION: "${{ needs.prepare.outputs.version }}"
run: |
# Prints all package.json files
PACKAGE_FILES=$(find . -path '**/node_modules' -prune -o -name 'package.json' -print)
for file in $PACKAGE_FILES; do
# Set "version" in package.json file to $VERSION.
TMP_FILE="$(mktemp)"
jq --arg v "$VERSION" '.version = $v' "$file" > "$TMP_FILE"
mv "$TMP_FILE" "$file"
done
# TODO(joshuasing): Install and use binaryen
- name: "Build @hemilabs/pop-miner WebAssembly binary"
working-directory: "web/"
run: make wasm
- name: "Build @hemilabs/pop-miner package"
working-directory: "web/"
run: pnpm build:pop-miner
- name: "Publish @hemilabs/pop-miner package"
working-directory: "web/"
run: pnpm publish packages/pop-miner --access public --no-git-checks
env:
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
# Create GitHub Release
release:
name: "Release"
runs-on: "ubuntu-latest"
needs: [ "test-go", "npm" ]
permissions:
# Required to create GitHub releases.
contents: write
# Required for Sigstore cosign authentication.
id-token: write
# Required to publish to GitHub Container Registry.
packages: write
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true
- name: "Install cosign"
uses: sigstore/[email protected]
- name: "Install Syft"
uses: anchore/sbom-action/[email protected]
- name: "Setup QEMU"
uses: docker/setup-qemu-action@v3
- name: "Setup Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "Login to DockerHub"
uses: docker/login-action@v3
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_TOKEN }}"
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: "ghcr.io"
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Release"
uses: goreleaser/goreleaser-action@v6
with:
distribution: "goreleaser"
version: "~> v2"
args: "release --clean"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"