-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (133 loc) · 4.68 KB
/
publish.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
name: publish
on:
push:
branches: ['main']
tags:
- 'v*.*.*'
concurrency: ${{ github.ref }}
jobs:
create-draft-release:
runs-on: ubuntu-latest
outputs:
RELEASE_ID: ${{ steps.create-release.outputs.result }}
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/github-script@v7
id: create-release
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
try {
const response = await github.rest.repos.createRelease({
draft: true,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
return response.data.id;
} catch (error) {
core.setFailed(error.message);
}
build-binaries:
strategy:
matrix:
os: [linux, darwin]
arch: [amd64, arm64]
runs-on: ubuntu-latest
needs: [create-draft-release]
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Build binary
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build
- name: Upload release asset
if: startsWith(github.ref, 'refs/tags/')
run: |
_filename=node-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}
mv node ${_filename}
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @${_filename} \
https://uploads.github.com/repos/${{ github.repository_owner }}/node/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename}
build-images:
runs-on: ubuntu-latest
needs: [create-draft-release]
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: blinklabs
password: ${{ secrets.DOCKER_PASSWORD }} # uses token
- name: Login to GHCR
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- id: meta
uses: docker/metadata-action@v5
with:
images: |
blinklabs/node
ghcr.io/${{ github.repository }}
tags: |
# Only version, no revision
type=match,pattern=v(.*)-(.*),group=1
# branch
type=ref,event=branch
# semver
type=semver,pattern={{version}}
- name: Build images
uses: docker/build-push-action@v6
with:
outputs: "type=registry,push=true"
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Update Docker Hub from README
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: blinklabs
password: ${{ secrets.DOCKER_PASSWORD }}
repository: blinklabs/node
readme-filepath: ./README.md
short-description: "Cardano Blockchain Node"
finalize-release:
runs-on: ubuntu-latest
needs: [create-draft-release, build-binaries, build-images]
steps:
- uses: actions/github-script@v7
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-draft-release.outputs.RELEASE_ID }},
draft: false,
});
} catch (error) {
core.setFailed(error.message);
}
# This updates the documentation on pkg.go.dev and the latest version available via the Go module proxy
- name: Pull new module version
if: startsWith(github.ref, 'refs/tags/')
uses: andrewslotin/go-proxy-pull-action@v1.2.0