-
Notifications
You must be signed in to change notification settings - Fork 83
123 lines (101 loc) · 3.66 KB
/
build_and_release_snapshot.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
# You may want to know...
#
# Conditions:
# - Pushing any commits triggers building.
# - Pushing commits to "master" produces a snapshot.
#
# Q: This workflow will not triggered by releases. What if I want to release a new no-snapshot version?
# A: Manually create a release on GitHub with your customized release note, then download and upload
# the artifacts from the recent snapshot.
#
name: Build, and may release a new snapshot
on:
push:
pull_request:
workflow_dispatch:
env:
tag_name: "snapshot"
jobs:
build_artifacts:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/[email protected]
- name: Install node
uses: actions/[email protected]
with:
node-version-file: "./ui/.nvmrc"
cache: "npm"
cache-dependency-path: "./ui"
- name: Install golang
uses: actions/[email protected]
with:
go-version-file: "./go.mod"
- name: Install UI dependencies
working-directory: "./ui"
run: |
set -euo pipefail
npm ci
- name: Build version '${{ env.tag_name }}'
run: |
set -euo pipefail
./scripts/prep_release.sh '${{ env.tag_name }}'
- name: Upload artifacts
uses: actions/[email protected]
with:
if-no-files-found: error
name: gohls-${{ env.tag_name }}-all_in_one
path: "./build/gohls-*-${{ env.tag_name }}.tar.gz"
make_release:
# https://docs.github.com/en/actions/learn-github-actions/contexts
# https://docs.github.com/actions/learn-github-actions/expressions
if: ${{ github.ref == 'refs/heads/master' }}
needs: build_artifacts
runs-on: ubuntu-latest
permissions:
contents: write
# https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/
concurrency:
group: std::lock_guard
cancel-in-progress: true
timeout-minutes: 10
steps:
# for deleting existing tag later
- uses: actions/[email protected]
- name: Download artifacts
uses: actions/[email protected]
with:
name: gohls-${{ env.tag_name }}-all_in_one
- name: Delete existing tag '${{ env.tag_name }}' if it exists
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
set -x
if gh release view '${{ env.tag_name }}'; then
gh release delete '${{ env.tag_name }}' --cleanup-tag --yes
# GitHub seems to need some time to clean things up.
# If there is no sleep, a draft release may be generated.
sleep 60
fi
- name: Tag and release '${{ env.tag_name }}'
uses: svenstaro/[email protected]
with:
tag: "${{ env.tag_name }}"
file: "./gohls-*-${{ env.tag_name }}.tar.gz"
file_glob: true
prerelease: true
release_name: "${{ env.tag_name }}"
body: "The ${{ env.tag_name }} release."
- name: Push to AWS S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
set -euo pipefail
aws s3 cp --region us-east-1 './gohls-osx-${{ env.tag_name }}.tar.gz' s3://gohls/
aws s3 cp --region us-east-1 './gohls-osx-arm64-${{ env.tag_name }}.tar.gz' s3://gohls/
aws s3 cp --region us-east-1 './gohls-linux-386-${{ env.tag_name }}.tar.gz' s3://gohls/
aws s3 cp --region us-east-1 './gohls-linux-amd64-${{ env.tag_name }}.tar.gz' s3://gohls/
aws s3 cp --region us-east-1 './gohls-linux-arm64-${{ env.tag_name }}.tar.gz' s3://gohls/
aws s3 cp --region us-east-1 './gohls-windows-amd64-${{ env.tag_name }}.tar.gz' s3://gohls/