forked from letsencrypt/pebble
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (157 loc) · 4.9 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
name: Build Release
# Run on semver tags.
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: read
packages: write # Allow docker/build-push-action to publish to GitHub Container Registry
env:
DOCKER_PLATFORMS: linux/amd64, linux/arm64, windows/amd64
DOCKER_IMAGE_BASENAME: ghcr.io/${{ github.repository_owner }}
jobs:
go-build:
env:
CGO_ENABLED: 0
GOARCH: ${{ matrix.go-arch }}
GOOS: ${{ matrix.go-os }}
LDFLAGS: -s -w -X 'main.version=${{ github.ref_name }} (${{ github.sha }})'
OUTPUTDIR: /tmp/dist/${{ matrix.go-os }}/${{ matrix.go-arch }}
runs-on: ubuntu-latest
strategy:
matrix:
app:
- pebble
- pebble-challtestsrv
go-arch:
- amd64
- arm64
go-os:
- darwin
- linux
- windows
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: go.mod
- name: Build ${{ matrix.app }} for ${{ matrix.go-os }}/${{ matrix.go-arch }}
run: |
go build \
-ldflags="${LDFLAGS}" \
-o "${OUTPUTDIR}/" \
-trimpath \
-v \
./cmd/${{ matrix.app }}
- name: Display ${{ matrix.app }} artifacts
run: tree /tmp/dist
- name: Store ${{ matrix.app }} artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.app }}-${{ matrix.go-os }}-${{ matrix.go-arch }}
path: /tmp/dist
docker-build:
needs:
- go-build
runs-on: ubuntu-latest
strategy:
matrix:
app:
- pebble
- pebble-challtestsrv
steps:
- uses: actions/checkout@v4
- name: Download ${{ matrix.app }} artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: /tmp/dist
pattern: ${{ matrix.app }}-*-*
- name: Display ${{ matrix.app }} artifacts
run: tree /tmp/dist
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_BASENAME }}/${{ matrix.app }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=sha
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ github.repository }}/${{ matrix.app }} for ${{ env.DOCKER_PLATFORMS }}
uses: docker/build-push-action@v5
with:
build-args: APP=${{ matrix.app }}
build-contexts: dist-files=/tmp/dist
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.release
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: ${{ steps.meta.outputs.tags }}
docker-version:
needs:
- docker-build
runs-on: ${{ matrix.docker-os }}
strategy:
matrix:
docker-os:
- ubuntu-latest
- windows-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Display pebble version in container image
run: docker run ${{ env.DOCKER_IMAGE_BASENAME }}/pebble:latest -version
create-release:
needs:
- go-build
permissions:
contents: write # Allow creation of a release
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
- name: Display build artifacts
run: tree .
- name: Create release
# https://cli.github.com/manual/gh_release_create
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.ref_name }} \
--repo ${{ github.repository }} \
--title "${{ github.ref_name }}" \
--verify-tag
continue-on-error: true
- name: Upload release files
# https://cli.github.com/manual/gh_release_upload
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
for artifact in *; do
tar czf ${artifact}.tar.gz ${artifact}
zip -r ${artifact}.zip ${artifact}
gh release upload ${{ github.ref_name }} ${artifact}.* \
--repo ${{ github.repository }};
done