1
0
forked from MTSR/mapserver

70 lines
1.7 KiB
YAML
Raw Normal View History

2022-02-01 14:51:25 +01:00
name: build
on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
2022-03-06 10:56:24 +00:00
uses: actions/checkout@v3
2022-02-01 14:51:25 +01:00
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3.5.0
2022-02-01 14:51:25 +01:00
with:
go-version: 1.18
2022-02-01 14:51:25 +01:00
- name: Set up nodejs
2022-02-25 08:19:10 +00:00
uses: actions/setup-node@v3
2022-02-01 14:51:25 +01:00
with:
node-version: '17'
2022-02-01 14:53:18 +01:00
- name: Create frontend bundle
2022-02-01 14:51:25 +01:00
run: cd public && npm ci && npm run bundle
- name: Cache Go modules
2022-12-16 07:21:11 +00:00
uses: actions/cache@v3
2022-02-01 14:51:25 +01:00
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tests
run: |
2022-02-01 15:47:34 +01:00
go test ./...
2022-02-01 14:51:25 +01:00
# only on tags or the master branch
2022-02-01 14:51:25 +01:00
- name: Docker Login
if: success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')
2022-02-01 14:51:25 +01:00
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# only on tags
2022-02-01 14:51:25 +01:00
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
2022-02-01 15:31:42 +01:00
if: success() && startsWith(github.ref, 'refs/tags/')
2022-02-01 14:51:25 +01:00
with:
version: latest
args: release --rm-dist
env:
2022-02-01 15:34:00 +01:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# only on the master branch
2022-02-01 15:39:49 +01:00
- name: Build and push latest docker image
2022-02-01 15:34:00 +01:00
if: success() && github.ref == 'refs/heads/master'
2022-02-01 15:39:49 +01:00
run: |
2022-02-01 15:58:38 +01:00
CGO_ENABLED=0 go build .
2022-02-01 15:39:49 +01:00
docker build . -t minetestmapserver/mapserver:latest
docker push minetestmapserver/mapserver:latest