Update GitHub Actions workflows

This commit is contained in:
Matthew Penner 2020-12-15 15:59:06 -07:00
parent fafda283b1
commit 02034211c1
4 changed files with 74 additions and 58 deletions

View File

@ -12,7 +12,6 @@ on:
jobs: jobs:
build: build:
strategy: strategy:
# Default is true, cancels jobs for other platforms in the matrix if one fails
fail-fast: false fail-fast: false
matrix: matrix:
@ -24,9 +23,11 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - name: Code Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2 - name: Setup Go v${{ matrix.go }}
uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
@ -64,22 +65,14 @@ jobs:
SRC_PATH: github.com/pterodactyl/wings SRC_PATH: github.com/pterodactyl/wings
run: | run: |
go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o build/wings_${{ matrix.goos }}_${{ matrix.goarch }} wings.go go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o build/wings_${{ matrix.goos }}_${{ matrix.goarch }} wings.go
upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
- name: Test - name: Test
run: go test ./... run: go test ./...
- name: Compress binary and make it executable - name: Upload Artifact
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} uses: actions/upload-artifact@v2
run: |
upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }} && chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
- uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}
with:
name: wings_${{ matrix.goos }}_${{ matrix.goarch }}
path: build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
- uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}
with: with:
name: wings_${{ matrix.goos }}_${{ matrix.goarch }} name: wings_${{ matrix.goos }}_${{ matrix.goarch }}

View File

@ -1,30 +1,42 @@
name: CodeQL Scanning name: CodeQL
on: on:
push: push:
branches: branches:
- 'develop' - 'develop'
pull_request: pull_request:
branches:
- 'develop'
schedule:
- cron: '0 9 * * 4'
jobs: jobs:
CodeQL-Build: analyze:
runs-on: ubuntu-latest name: Analyze
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
language:
- go
steps: steps:
- name: Checkout repository - name: Code Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2 fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit. - name: Checkout Head
- run: git checkout HEAD^2 run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with: with:
languages: go languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v1

View File

@ -1,47 +1,55 @@
name: Publish Docker Image name: Publish Docker Image
on: on:
push: push:
branches: branches:
- 'develop' - 'develop'
tags: tags:
- 'v*' - 'v*'
jobs: jobs:
push_to_registry: push:
name: Push Image to GitHub Packages name: Push
runs-on: ubuntu-latest runs-on: ubuntu-20.04
# Always run against a tag, even if the commit into the tag has [docker skip]
# within the commit message. # Always run against a tag, even if the commit into the tag has [docker skip] within the commit message.
if: "!contains(github.ref, 'develop') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))" if: "!contains(github.ref, 'develop') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))"
steps: steps:
- uses: actions/checkout@v2 - name: Code Checkout
- uses: crazy-max/ghaction-docker-meta@v1 uses: actions/checkout@v2
id: docker_meta
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Install buildx
uses: docker/setup-buildx-action@v1
with: with:
images: ghcr.io/pterodactyl/wings version: v0.5.1
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1 - name: Login to GitHub Container Registry
- uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Release Production Build - name: Release Production Build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
if: "!contains(github.ref, 'develop')" if: "!contains(github.ref, 'develop')"
env:
REF: ${{ github.ref }}
with: with:
push: true
build-args: | build-args: |
VERSION=${REF:11} VERSION=${GITHUB_REF:11}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }} labels: ${{ steps.docker_meta.outputs.labels }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
- name: Release Development Build - name: Release Development Build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
if: "contains(github.ref, 'develop')" if: "contains(github.ref, 'develop')"
with: with:
push: ${{ github.event_name != 'pull_request' }}
build-args: | build-args: |
VERSION=dev-${GIT_COMMIT:0:7} VERSION=dev-$(git rev-parse --short "$GITHUB_SHA"}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }} labels: ${{ steps.docker_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}

View File

@ -1,18 +1,21 @@
name: Create Release name: Create Release
on: on:
push: push:
tags: tags:
- 'v*' - 'v*'
jobs: jobs:
release: release:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - name: Code Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2 - uses: actions/setup-go@v2
with: with:
go-version: '1.15.2' go-version: '1.15.6'
- name: Build - name: Build
env: env: