-
Notifications
You must be signed in to change notification settings - Fork 111
169 lines (145 loc) · 4.29 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
name: Release
on:
push:
tags:
- "v*"
jobs:
linux64:
name: Compile for Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ^1.17
- run: go mod download
- name: compile
run: |
go build \
-ldflags "-extldflags -static -X main.VERSION=${VERSION##*/v}" \
-o dist/authn-linux64
env:
VERSION: ${{ github.ref }}
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 1
- uses: actions/upload-artifact@v4
with:
name: authn-linux64
path: dist/authn-linux64
windows64:
name: Compile for Windows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ^1.17
- run: go mod download
- run: sudo apt install mingw-w64
- name: compile
run: |
go build \
-ldflags "-X main.VERSION=${VERSION##*/v}" \
-o dist/authn-windows64.exe
env:
VERSION: ${{ github.ref }}
GOOS: windows
GOARCH: amd64
CGO_ENABLED: 1
CC: x86_64-w64-mingw32-gcc
- uses: actions/upload-artifact@v4
with:
name: authn-windows64.exe
path: dist/authn-windows64.exe
macos64:
name: Compile for MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ^1.17
- run: go mod download
- name: compile
run: |
go build \
-ldflags "-X main.VERSION=${VERSION##*/v}" \
-o dist/authn-macos64
env:
VERSION: ${{ github.ref }}
GOOS: darwin
GOARCH: amd64
CGO_ENABLED: 1
- uses: actions/upload-artifact@v4
with:
name: authn-macos64
path: dist/authn-macos64
release:
name: Create Release
runs-on: ubuntu-latest
needs: [linux64, windows64, macos64]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
- name: Upload Linux64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./authn-linux64/authn-linux64
asset_name: authn-linux64
asset_content_type: application/octet-stream
- name: Upload Windows64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./authn-windows64.exe/authn-windows64.exe
asset_name: authn-windows64.exe
asset_content_type: application/vnd.microsoft.portable-executable
- name: Upload Macos64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./authn-macos64/authn-macos64
asset_name: authn-macos64
asset_content_type: application/octet-stream
register:
name: Register on Docker Hub
runs-on: ubuntu-latest
needs: release
steps:
- name: Get Dockerfile
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: authn-linux64
- run: |
chmod a+x authn-linux64
- name: VERSION
id: version
run: |
echo "::set-output name=number::${VERSION##*/v}"
env:
VERSION: ${{ github.ref }}
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
repository: keratin/authn-server
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
tags: latest,${{ steps.version.outputs.number }}