Skip to content

Adding flag to pull previous deploy settings #19

Adding flag to pull previous deploy settings

Adding flag to pull previous deploy settings #19

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version
id: set-version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(git rev-parse HEAD)
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
test:
name: Test on ${{ matrix.os.name }}
runs-on: ${{ matrix.os.runner }}
strategy:
matrix:
os:
- name: Linux
runner: ubuntu-latest
- name: Windows
runner: windows-latest
- name: macOS
runner: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Lint
run: make lint
- name: Build
run: make build
- name: Test
run: make test
publish-container-images:
name: Publish container images
runs-on: ubuntu-latest
needs: [prepare, test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/hathora/ci
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
flavor: |
latest=auto
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/bake-action@v2
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: default
push: ${{ github.event_name != 'pull_request' }}
publish-binaries:
name: Publish binary for ${{ matrix.os }} ${{ matrix.arch }}
runs-on: ubuntu-latest
needs: [prepare, test]
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binaries
env:
TARGETOS: ${{ matrix.os }}
TARGETARCH: ${{ matrix.arch }}
BUILD_VERSION: ${{ needs.prepare.outputs.version }}
run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: hathora-cli-${{ matrix.os }}-${{ matrix.arch }}
path: bin/hathora-ci-*
release:
name: Release
runs-on: ubuntu-latest
needs: [publish-container-images, publish-binaries]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: bin
pattern: hathora-ci-*
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/*
generate_release_notes: true