-
Notifications
You must be signed in to change notification settings - Fork 219
172 lines (166 loc) · 5.38 KB
/
ci.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
name: CI
on:
push:
workflow_dispatch:
jobs:
test_build:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
check-latest: true
- name: "Place wintun.dll"
run: cp deps/wintun/bin/amd64/wintun.dll ./
- name: build
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --clean --snapshot
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
check-latest: true
- name: Get go version
id: go-version
run: echo "name=version::$(go env GOVERSION)" >> $GITHUB_OUTPUT
- name: go mod download
run: go mod download
- name: go mod verify
run: go mod verify
- name: generate command strings
run: go generate ./... && git diff --exit-code
- name: "Place wintun.dll"
run: cp deps/wintun/bin/amd64/wintun.dll ./
- name: Run tests
run: make test
release:
needs: test
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'dev-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
check-latest: true
- name: Get go version
id: go-version
run: echo "name=version::$(go env GOVERSION)" >> $GITHUB_OUTPUT
- name: Docker Login
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Place wintun.dll
run: cp -r deps/wintun/bin/amd64/wintun.dll ./
- name: generate release notes
run: |
mkdir -p ./tmp
./scripts/changelog.sh > ./tmp/changelog.txt
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean --release-notes=./tmp/changelog.txt
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
- name: Upload checksums as artifact
uses: actions/upload-artifact@v3
with:
name: checksums
path: dist/checksums.txt
sync_docs:
needs: release
runs-on: ubuntu-latest
if: ${{ !contains(github.ref, 'pre') }}
steps:
- name: Checkout flyctl
uses: actions/checkout@v3
- name: Checkout docs
uses: actions/checkout@v3
with:
repository: superfly/docs
token: ${{ secrets.DOCS_GITHUB_TOKEN }}
path: docs
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
check-latest: true
- name: Publish CLI docs
id: publish-cli-docs
env:
GITHUB_TOKEN: ${{ secrets.DOCS_GITHUB_TOKEN }}
run: scripts/publish_docs.sh ${{ github.ref_name }}
dev_release:
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'dev-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
check-latest: true
- name: Get go version
id: go-version
run: echo "name=version::$(go env GOVERSION)" >> $GITHUB_OUTPUT
- name: Place wintun.dll
run: cp -r deps/wintun/bin/amd64/wintun.dll ./
- name: generate release notes
run: |
mkdir -p ./tmp
./scripts/changelog.sh > ./tmp/changelog.txt
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --config .goreleaser.dev.yml --rm-dist --release-notes=./tmp/changelog.txt
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
- name: Upload checksums as artifact
uses: actions/upload-artifact@v3
with:
name: checksums
path: dist/checksums.txt
aur-publish:
name: Build & publish to AUR
needs: release
if: ${{ !contains(github.ref, 'pre') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download checksums
uses: actions/download-artifact@v3
with:
name: checksums
- name: Generate PKGBUILD
run: |
mkdir -p aur/flyctl-bin
export tag=${GITHUB_REF#refs/*/}
export version=${tag:1}
export sha256sum=$(grep "Linux_x86_64.tar.gz" checksums.txt | cut -d ' ' -f 1)
envsubst '${version},${sha256sum}' < aur/PKGBUILD > aur/flyctl-bin/PKGBUILD
cat aur/flyctl-bin/PKGBUILD
- name: Publish flyctl-bin to the AUR
uses: superfly/aur-releaser@ba29a0a809d7221713a104f9c9a23c34ee5b0742
with:
pkgname: flyctl-bin
pkgbuild: ./aur/flyctl-bin/PKGBUILD
commit_username: jeromegn
commit_email: jeromegn@gmail.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: ${{ github.event.ref }}
force_push: "true"