forked from stevearc/pair-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (130 loc) · 4.14 KB
/
test-and-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
name: Test and Build
on:
push:
branches:
- "*"
tags:
- "v*"
pull_request:
branches:
- "*"
schedule:
- cron: "0 12 * * *"
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
build_type: ${{ steps.git_check.outputs.build_type }}
steps:
- uses: actions/checkout@v2
- name: print latest_commit
run: echo ${{ github.sha }}
- id: git_check
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -n "$(git rev-list --after="24 hours" @)" && echo "::set-output name=build_type::nightly"
lint-job:
runs-on: ubuntu-latest
name: Lint and build Javascript
needs: check_date
if: ${{ github.event.schedule == null || needs.check_date.outputs.build_type == 'nightly' }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "16"
cache: "yarn"
- run: yarn install
- run: yarn lint
- run: yarn release
- run: yarn release-static
- name: "Upload build artifacts"
if: ${{ needs.check_date.outputs.build_type == 'nightly' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
uses: actions/upload-artifact@v2
with:
name: js-bundle
path: "server/dist/*"
retention-days: 5
- name: "Upload static site build artifacts"
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
uses: actions/upload-artifact@v2
with:
name: static-js-bundle
path: "static/*"
retention-days: 5
release-nightly:
runs-on: ubuntu-latest
name: Nightly release
needs: [check_date, lint-job]
if: ${{ needs.check_date.outputs.build_type == 'nightly' }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.17"
- name: Download js-bundle
uses: actions/download-artifact@v2
with:
name: js-bundle
path: server/dist
- run: GOOS=linux GOARCH=amd64 go build -o pair-ls-linux64
- run: GOOS=darwin GOARCH=amd64 go build -o pair-ls-mac
- run: GOOS=windows GOARCH=amd64 go build -o pair-ls.exe
- uses: dev-drprasad/delete-tag-and-release@v0.2.0
continue-on-error: true
with:
delete_release: true
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: true
files: |
pair-ls-*
pair-ls.exe
name: nightly
tag_name: nightly
release-version:
name: Cut release
needs: lint-job
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
environment: production
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.17"
- name: Download js-bundle
uses: actions/download-artifact@v2
with:
name: js-bundle
path: server/dist
- run: mkdir -p static
- name: Download static-js-bundle
uses: actions/download-artifact@v2
with:
name: static-js-bundle
path: static
- run: GOOS=linux GOARCH=amd64 go build -o pair-ls-linux64
- run: GOOS=darwin GOARCH=amd64 go build -o pair-ls-mac
- run: GOOS=windows GOARCH=amd64 go build -o pair-ls.exe
- run: ./publish-static-site.sh
env:
# Unfortunate hack https://github.com/aws/aws-cli/issues/5262#issuecomment-705832151
AWS_EC2_METADATA_DISABLED: "true"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
pair-ls-*
pair-ls.exe