-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (120 loc) · 3.46 KB
/
release-image.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
name: Release Go Project/Release ghcr image
on:
push:
tags: v*
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Check out code into Go module dir
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test code
run: go test -v .
setup-release:
name: Setup release
needs: test
runs-on: ubuntu-latest
steps:
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: Release ${{github.ref}}
draft: false
prerelease: false
- name: Get url to upload the release
env:
url: ${{ steps.create_release.outputs.upload_url }}
run: |
mkdir artifact
echo $url > artifact/url.txt
- name: Upload artifact to share url with jobs
uses: actions/upload-artifact@v1
with:
name: artifact
path: artifact/url.txt
release-pkg:
name: Release package
needs: setup-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [mac64, lin64, win64]
include:
- os: mac64
goos: darwin
arch: amd64
- os: lin64
goos: linux
arch: amd64
- os: win64
goos: windows
arch: amd64
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Check out code into go module dir
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Build
env:
goos: ${{matrix.goos}}
goarch: ${{matrix.arch}}
run: |
mkdir dist
GOOS=$goos GOARCH=$goarch go build -v -o dist/concordium-exporter .
zip -j -r release dist
- name: Download artifact to get url to upload
uses: actions/download-artifact@v1
with:
name: artifact
- name: Get url from artifact
id: get_url
run: |
url=$(cat artifact/url.txt)
echo "##[set-output name=upload_url;]$url"
- name: Upload release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.get_url.outputs.upload_url}}
asset_path: release.zip
asset_name: release-${{matrix.os}}.zip
asset_content_type: application/zip
docker_build_push:
runs-on: ubuntu-latest
env:
IMAGE_NAME: concordium-exporter
steps:
- name: Checkout code into dir
uses: actions/checkout@v2
- name: Setup docker buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.repository_owner}}
password: ${{secrets.GHCR_TOKEN}}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}}:latest
ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}}:${{github.sha}}