wings/.github/workflows/push.yaml

101 lines
2.8 KiB
YAML
Raw Normal View History

2022-11-06 20:55:49 +00:00
name: Push
2020-07-04 21:29:03 +00:00
on:
push:
branches:
- develop
2020-07-04 21:29:03 +00:00
pull_request:
branches:
- develop
2022-11-06 20:55:49 +00:00
2020-07-04 21:29:03 +00:00
jobs:
2022-11-06 20:55:49 +00:00
build-and-test:
name: Build and Test
runs-on: ${{ matrix.os }}
2020-10-17 21:13:06 +00:00
strategy:
fail-fast: false
matrix:
2022-11-06 20:55:49 +00:00
os: [ubuntu-20.04]
2023-01-13 18:07:09 +00:00
go: ["1.18.10", "1.19.5"]
2022-11-06 20:55:49 +00:00
goos: [linux]
goarch: [amd64, arm64]
2020-07-04 21:29:03 +00:00
steps:
2022-11-06 20:55:49 +00:00
- name: Setup Go
uses: actions/setup-go@v3
2020-07-04 21:29:03 +00:00
with:
2020-10-17 21:13:06 +00:00
go-version: ${{ matrix.go }}
2022-11-06 20:55:49 +00:00
- name: Code Checkout
uses: actions/checkout@v3
- name: Gather environment variables
2020-12-06 23:12:41 +00:00
id: env
run: |
printf "Go Executable Path: $(which go)\n"
printf "Go Version: $(go version)\n"
printf "\n\nGo Environment:\n\n"
go env
printf "\n\nSystem Environment:\n\n"
env
printf "Git Version: $(git version)\n\n"
2022-11-06 20:55:49 +00:00
echo "version_tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go_mod_cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
2020-12-06 23:12:41 +00:00
- name: Build Cache
2022-11-06 20:55:49 +00:00
uses: actions/cache@v3
2020-12-06 23:12:41 +00:00
with:
2022-11-06 20:55:49 +00:00
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2020-12-06 23:12:41 +00:00
restore-keys: |
2022-11-06 20:55:49 +00:00
${{ runner.os }}-go-
path: |
${{ steps.env.outputs.go_cache }}
${{ steps.env.outputs.go_mod_cache }}
2022-11-06 20:55:49 +00:00
- name: go mod download
env:
CGO_ENABLED: 0
2020-12-06 23:12:41 +00:00
run: |
2022-11-06 20:55:49 +00:00
go mod download
2020-07-04 21:29:03 +00:00
- name: Build
2020-10-17 21:13:06 +00:00
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
2020-12-06 23:12:41 +00:00
SRC_PATH: github.com/pterodactyl/wings
2020-10-17 20:52:38 +00:00
run: |
2022-11-06 20:55:49 +00:00
go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o dist/wings ${SRC_PATH}
go build -v -trimpath -ldflags="-X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o dist/wings_debug ${SRC_PATH}
chmod 755 dist/*
- name: go test
2022-11-06 21:39:02 +00:00
if: ${{ matrix.goarch == 'amd64' }}
2022-11-06 20:55:49 +00:00
env:
CGO_ENABLED: 0
run: |
go test $(go list ./...)
- name: go test -race
if: ${{ matrix.goarch == 'amd64' }}
env:
CGO_ENABLED: 1
run: |
go test -race $(go list ./...)
2022-01-30 20:06:56 +00:00
- name: Upload Release Artifact
2020-12-15 22:59:06 +00:00
uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}
2020-10-17 20:52:38 +00:00
with:
2022-01-30 20:06:56 +00:00
name: wings_linux_${{ matrix.goarch }}
2022-11-06 20:55:49 +00:00
path: dist/wings
2022-01-30 20:06:56 +00:00
- name: Upload Debug Artifact
uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}
with:
name: wings_linux_${{ matrix.goarch }}_debug
2022-11-06 20:55:49 +00:00
path: dist/wings_debug