-
Notifications
You must be signed in to change notification settings - Fork 240
154 lines (144 loc) · 4.37 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
name: Build & Release
on:
push:
tags:
- v**
workflow_run:
workflows: ["Automatically release a new version of flyctl"]
types:
- completed
workflow_dispatch:
# need this until this file is on the default branch so tag creates are picked up
workflow_call:
permissions:
contents: write
packages: write
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
jobs:
debug:
runs-on: ubuntu-latest
steps:
- run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
meta:
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.gen.outputs.sha_short }}
json: ${{ steps.gen.outputs.json }}
version: ${{ fromJSON(steps.gen.outputs.json).version }}
tag: ${{ fromJSON(steps.gen.outputs.json).tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Generate release meta
run: |
go run ./tools/version show > release.json
- name: Output release meta
id: gen
run: |
cat release.json | jq
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "json=$(cat release.json)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
release.json
overwrite: true
build:
needs: meta
strategy:
matrix:
GOOS: [linux, windows, darwin]
runs-on: ubuntu-latest-m
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Place wintun.dll
run: cp -r deps/wintun/bin/amd64/wintun.dll ./
- id: cache
uses: actions/cache@v4
with:
path: dist/${{ matrix.GOOS }}
key: ${{ matrix.GOOS }}-${{ needs.meta.outputs.sha_short }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.FLYIOBUILDS_DOCKERHUB_USERNAME }}
password: ${{ secrets.FLYIOBUILDS_DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser-pro
version: latest
args: release --clean -f .goreleaser.2.yml --fail-fast --split
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GGOOS: ${{ matrix.GOOS }}
release:
runs-on: ubuntu-latest
needs: [meta, build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
# copy the caches from prepare
- uses: actions/cache@v4
with:
path: dist/linux
key: linux-${{ needs.meta.outputs.sha_short }}
- uses: actions/cache@v4
with:
path: dist/darwin
key: darwin-${{ needs.meta.outputs.sha_short }}
- uses: actions/cache@v4
with:
path: dist/windows
key: windows-${{ needs.meta.outputs.sha_short }}
- name: Write release meta
env:
RELEASE_JSON: ${{ needs.meta.outputs.json }}
run: echo "$RELEASE_JSON" > ./dist/release.json
- uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/**/*.json
dist/**/*.zip
dist/**/*.tar.gz
retention-days: 1
overwrite: true
- name: Github release
if: steps.cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser-pro
version: latest
args: continue --merge
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GGOOS: ${{ matrix.GOOS }}