Merge pull request #2 from ncpleslie/feature/decouple-frontend #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release WMATA Train Tracker | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
contents: read | |
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, | |
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/[email protected] | |
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 wmata-train-tracker.tar -C build/bin . | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Wails Build ${{runner.os}} ${{matrix.build.name}} | |
path: wmata-train-tracker.tar |