-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (158 loc) · 5.06 KB
/
action.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
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build and Release WMATA Train Tracker
on:
push:
branches:
- main
pull_request:
release:
types: [created]
permissions:
contents: write
jobs:
lint-go:
name: Lint - Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
test-go:
name: Test - Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Build frontend
run: |
cd frontend
pnpm install
pnpm build
- uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- name: Install dependencies
run: go get .
- name: Run tests
run: go test ./...
build:
name: Build - Wails
needs: [lint-go, test-go]
strategy:
fail-fast: false
matrix:
build: [
{
name: wmata-train-tracker-linux,
platform: linux/amd64,
os: ubuntu-latest,
},
# TODO: Build for MacOS and Windows
# { name: wmata-train-tracker, platform: windows/amd64, os: windows-latest },
# { name: wmata-train-tracker, platform: darwin/universal, os: macos-latest },
]
runs-on: ${{ matrix.build.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- uses: ncpleslie/wails-build-action@v2.2
with:
build-name: ${{ matrix.build.name }}
build-platform: ${{ matrix.build.platform }}
go-version: "1.21"
node-version: 18
package: false
- name: Create Config File
run: |
echo "BASE_URL=${{ vars.BASE_URL }}" > build/bin/config.cfg
echo "TRAIN_UPDATE_IN_SECONDS=${{ vars.TRAIN_UPDATE_IN_SECONDS }}" >> build/bin/config.cfg
echo "TRAIN_ROUTE=${{ vars.TRAIN_ROUTE }}" >> build/bin/config.cfg
echo "INCIDENT_UPDATE_IN_SECONDS=${{ vars.INCIDENT_UPDATE_IN_SECONDS }}" >> build/bin/config.cfg
echo "INCIDENT_ROUTE=${{ vars.INCIDENT_ROUTE }}" >> build/bin/config.cfg
echo "STATIONS_ROUTE=${{ vars.STATIONS_ROUTE }}" >> build/bin/config.cfg
echo "STATION_BY_ID_ROUTE=${{ vars.STATION_BY_ID_ROUTE }}" >> build/bin/config.cfg
echo "DEFAULT_STATION_ID=${{ vars.DEFAULT_STATION_ID }}" >> build/bin/config.cfg
echo "SQLITE_URL=${{ vars.SQLITE_URL }}" >> build/bin/config.cfg
- name: Make executable
if: runner.os == 'Linux'
run: chmod +x build/bin/*
# Tar the application to preserve permissions set by previous step
- name: Tar files
if: runner.os == 'Linux'
run: tar -cvf ${{matrix.build.name}}.tar -C build/bin .
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{matrix.build.name}}
path: ${{matrix.build.name}}.tar
release:
name: Release
needs: [build]
strategy:
matrix:
build: [
{ name: wmata-train-tracker-linux },
# TODO: Build for MacOS and Windows
# { name: wmata-train-tracker, platform: windows/amd64, os: windows-latest },
# { name: wmata-train-tracker, platform: darwin/universal, os: macos-latest },
]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: ${{matrix.build.name}}
path: artifacts
- uses: softprops/action-gh-release@v1
with:
files: artifacts/*