-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (156 loc) · 5.16 KB
/
perform-release.yaml
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
name: Create a release on VERSION update
on:
push:
branches:
- main
paths:
- assets/VERSION
jobs:
integration-test:
name: Run integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Unit Test
run: go test ./...
create-release-tag:
name: Create release tag
runs-on: ubuntu-latest
needs:
- integration-test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
const fs = require('fs');
const version = fs.readFileSync('assets/VERSION', 'utf8').trim();
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/v${version}`,
sha: context.sha
})
create-release:
name: Create a GH release from version tag
runs-on: ubuntu-latest
needs:
- create-release-tag
steps:
- uses: actions/checkout@v2
- name: Get version from VERSION file
id: get_version
run: |
echo ::set-output name=release_version::$(cat assets/VERSION | tr -d '[:space:]')
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.release_version }}
release_name: Release ${{ steps.get_version.outputs.release_version }}
draft: false
prerelease: false
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
publish-binaries:
runs-on: ubuntu-latest
needs:
- create-release
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ["386", amd64]
exclude:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Get version from VERSION file
id: get_version
run: echo ::set-output name=release_version::$(cat assets/VERSION | tr -d '[:space:]')
- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Set environment variables
env:
REPOSITORY_NAME: ${{ github.repository }}
ARTIFACT_DIR: ./artifacts
run: |
export BASE_NAME=${REPOSITORY_NAME##*/}
export BINARY_NAME="${BASE_NAME}-${{ steps.get_version.outputs.release_version }}-${{ matrix.goos }}-${{ matrix.goarch }}"
echo "binary_name=$BINARY_NAME" >> $GITHUB_ENV
echo "artifact_dir=$ARTIFACT_DIR" >> $GITHUB_ENV
echo "binary_path=${ARTIFACT_DIR}/${BINARY_NAME}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p "${{ env.artifact_dir }}"
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o "${{ env.binary_path }}"
sha256sum "${{ env.binary_path }}" | cut -d ' ' -f 1 > "${{ env.binary_path }}.sha256"
- name: Set upload URL
id: get_release_info
run: |
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.binary_path }}
asset_name: ${{ env.binary_name }}
asset_content_type: application/octet-stream
- name: Upload release SHA256 hash
id: upload-release-checksum
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.binary_path }}.sha256
asset_name: ${{ env.binary_name }}.sha256
asset_content_type: text/plain
update-version:
runs-on: ubuntu-latest
needs:
- publish-binaries
steps:
- uses: actions/checkout@v2
- name: Get version from VERSION file
id: get_version
run: echo ::set-output name=release_version::$(cat assets/VERSION | tr -d '[:space:]')
- name: Update version in CloudFlare K/V
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
publish: false
preCommands: wrangler kv:key put --namespace-id=dedba216553b445681f5043a2dcaee68 "installtest-version" ${{ steps.get_version.outputs.release_version }}
workingDirectory: download-page