-
Notifications
You must be signed in to change notification settings - Fork 26
147 lines (143 loc) · 5.62 KB
/
build.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
name: binaries
on:
push:
tags:
- 'v*'
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]
jobs:
frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache
with:
path: controller/web/template/dist
key: frontend-dist-${{ hashFiles('controller/web/template/**') }}
- uses: actions/setup-node@v1
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: '15.x'
- run: cd controller/web/template && npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: cd controller/web/template && npm run build --if-present
if: steps.cache.outputs.cache-hit != 'true'
package-templates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache2
with:
path: build-artifacts/templates.zip
key: templates-${{ hashFiles('templates/**') }}
- run: mkdir -p build-artifacts
if: steps.cache2.outputs.cache-hit != 'true'
- run: zip -qr build-artifacts/templates.zip templates
if: steps.cache2.outputs.cache-hit != 'true'
go-binaries:
runs-on: ubuntu-latest
needs: [ frontend, package-templates ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache
with:
path: controller/web/template/dist
key: frontend-dist-${{ hashFiles('controller/web/template/**') }}
- uses: actions/cache@v2
id: cache2
with:
path: build-artifacts/templates.zip
key: templates-${{ hashFiles('templates/**') }}
- uses: actions/setup-go@v2
with:
go-version: '^1.17.x'
- run: GOOS=linux GOARCH=amd64 go build -o build-artifacts/vistecture-linux-amd64 vistecture.go
- run: GOOS=linux GOARCH=arm64 go build -o build-artifacts/vistecture-linux-arm64 vistecture.go
- run: GOOS=windows go build -o build-artifacts/vistecture.exe vistecture.go
- uses: actions/upload-artifact@v4
with:
name: binaries
path: build-artifacts/vistecture*
createRelease:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [ go-binaries]
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Download go-binary artifact
uses: actions/download-artifact@v4
with:
name: binaries
path: ./
- name: Upload vistecture.exe asset
id: upload-windows-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./vistecture.exe
asset_name: vistecture.exe
asset_content_type: application/octet-stream
- name: Upload vistecture linux asset
id: upload-linux-asset-amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./vistecture-linux-amd64
asset_name: vistecture-amd64
asset_content_type: application/octet-stream
- name: Upload vistecture linux asset
id: upload-linux-asset-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./vistecture-linux-arm64
asset_name: vistecture-arm64
asset_content_type: application/octet-stream
docker:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [ go-binaries ]
steps:
- name: Checkout
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: Download go-binary artifact
uses: actions/download-artifact@v4
with:
name: binaries
path: build-artifacts
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v6
with:
context: .
file: .github/Dockerfile
push: true
tags: aoepeople/vistecture:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64