Skip to content

Merge pull request #5 from pufferpanel/v2 #38

Merge pull request #5 from pufferpanel/v2

Merge pull request #5 from pufferpanel/v2 #38

Workflow file for this run

name: Build
on:
push:
branches:
- v2
tags:
- v2.*
- v3.*
paths-ignore:
- '.github/workflows/release.yml'
- '.github/workflows/pr.yml'
env:
SWAG_VERSION: "1.8.8"
GO_VERSION: "1.19"
NODE_VERSION: "16"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
skip-build:
runs-on: ubuntu-20.04
if: "!startsWith(github.ref, 'refs/tags/v') && contains(github.event.head_commit.message, '[skip]') || startsWith(github.head_ref, 'l10n_master')"
name: "Build skipped"
timeout-minutes: 1
steps:
- name: Skipping
run: echo "Skipping build"
build-shared:
name: Build Shared Objects
runs-on: ubuntu-20.04
if: "startsWith(github.ref, 'refs/tags/v') || !(contains(github.event.head_commit.message, '[skip]') || startsWith(github.head_ref, 'l10n_master'))"
timeout-minutes: 10
steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^${{ env.GO_VERSION }}
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Restore NPM cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-nodemodules-${{ env.NODE_VERSION }}-${{ hashFiles('client/package-lock.json') }}
restore-keys: |
${{ runner.os }}-nodemodules-${{ env.NODE_VERSION }}
- name: Restore NPM cache
uses: actions/cache@v3
with:
path: client/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Restore Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Download Go Binaries
run: |
wget https://github.com/swaggo/swag/releases/download/v${{ env.SWAG_VERSION }}/swag_${{ env.SWAG_VERSION }}_Linux_x86_64.tar.gz
mkdir -p ~/go/bin
tar -zxf swag*.tar.gz -C ~/go/bin
rm -rf swag*.tar.gz
go get ./...
- name: npm install, build
run: |
npm install
npm run build
env:
CI: true
working-directory: client
- name: Generate Swagger Docs
run: |
~/go/bin/swag init -o web/swagger -g web/loader.go
- name: Upload Swagger docs
uses: actions/upload-artifact@v3
with:
name: pufferpanel_swagger
path: |
web/swagger/swagger.json
web/swagger/swagger.yaml
if-no-files-found: error
- name: Generate folders and remove excess files
run: |
mkdir -p build-artifacts/www
mv client/dist/* build-artifacts/www
mv assets/email build-artifacts
rm -rf .git .github client web/swagger/swagger.json web/swagger/swagger.yaml build-artifacts/www/js/*.map
- name: Generate job artifact
uses: actions/upload-artifact@v3
with:
name: pufferpanel_build_artifact
path: .
if-no-files-found: error
retention-days: 1
build-windows-amd64-binaries:
name: Build Binaries - Windows AMD64
runs-on: ubuntu-20.04
needs: ['build-shared']
timeout-minutes: 10
steps:
- name: Get the version
run: echo "VERSION=0.0.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^${{ env.GO_VERSION }}
- uses: actions/download-artifact@v2
with:
name: pufferpanel_build_artifact
- name: Download APT packages
run: |
sudo apt-get update
sudo apt-get install --download-only -y gcc-mingw-w64
- name: APT Install
run: |
sudo apt-get install -y gcc-mingw-w64
- name: Restore Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Build Windows
run: |
go build -o build-artifacts/pufferpanel.exe -ldflags "-X 'github.com/pufferpanel/pufferpanel/v2.Hash=${{ github.sha }}' -X 'github.com/pufferpanel/pufferpanel/v2.Version=${{ env.VERSION }}'" -v github.com/pufferpanel/pufferpanel/v2/cmd
env:
GOOS: windows
GOARCH: amd64
CC: x86_64-w64-mingw32-gcc
CXX: x86_64-w64-mingw32-g++
CGO_ENABLED: 1
- name: Publish Artifacts
uses: actions/upload-artifact@v1
with:
name: pufferpanel_${{ env.VERSION }}_windows_amd64
path: build-artifacts/
build-linux-amd64-binaries:
name: Build Binaries - Linux AMD64
runs-on: ubuntu-20.04
needs: ['build-shared']
timeout-minutes: 10
steps:
- name: Get the version
run: echo "VERSION=0.0.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^${{ env.GO_VERSION }}
- name: Download APT packages
run: |
sudo apt-get update
sudo apt-get install --download-only -y rpm
- name: APT Install
run: |
sudo apt-get install -y rpm
- uses: actions/download-artifact@v2
with:
name: pufferpanel_build_artifact
- name: Restore Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Build Linux
run: |
go build -o build-artifacts/pufferpanel -ldflags "-X 'github.com/pufferpanel/pufferpanel/v2.Hash=${{ github.sha }}' -X 'github.com/pufferpanel/pufferpanel/v2.Version=${{ env.VERSION }}'" -v github.com/pufferpanel/pufferpanel/v2/cmd
env:
GOOS: linux
GOARCH: amd64
- name: Set up build folder
run: |
mkdir -p DEBBUILD/usr/sbin DEBBUILD/var/www/pufferpanel DEBBUILD/var/lib/pufferpanel
mkdir -p DEBBUILD/var/log/pufferpanel DEBBUILD/etc/pufferpanel DEBBUILD/lib/systemd/system/
mkdir -p DEBBUILD/var/lib/pufferpanel/binaries
cp config.linux.json DEBBUILD/etc/pufferpanel/config.json
cp build-artifacts/pufferpanel DEBBUILD/usr/sbin/pufferpanel
cp -r build-artifacts/www/* DEBBUILD/var/www/pufferpanel
cp -r build-artifacts/email DEBBUILD/etc/pufferpanel
cp systemd/servicefiles/pufferpanel.service DEBBUILD/lib/systemd/system/pufferpanel.service
mkdir -p RPMBUILD/var/lib/pufferpanel RPMBUILD/var/log/pufferpanel RPMBUILD/var/lib/pufferpanel/binaries
- name: Build Package DEB AMD64
id: debamd64
uses: pufferpanel/build-deb@master
with:
data-folder: DEBBUILD
package: pufferpanel
version: ${{ env.VERSION }}
license: Apache 2.0
architecture: amd64
maintainer: PufferPanel <[email protected]>
homepage: https://pufferpanel.com
description: Game management server panel
before-install: systemd/scripts/preinstall.sh
after-install: systemd/scripts/postinstall.sh
before-upgrade: systemd/scripts/preupgrade.sh
after-upgrade: systemd/scripts/postupgrade.sh
before-remove: systemd/scripts/preremove.sh
after-remove: systemd/scripts/postremove.sh
after-purge: systemd/scripts/purge.sh
user: pufferpanel
group: pufferpanel
suggested-packages: |
java-runtime-headless
lib32gcc1
- name: Build Package RPM AMD64
id: rpmamd64
uses: pufferpanel/build-rpm@master
with:
package: pufferpanel
version: ${{ env.VERSION }}
license: Apache 2.0
architecture: x86_64
maintainer: PufferPanel <[email protected]>
website: https://pufferpanel.com
summary: Game management server panel
before-install: systemd/scripts/preinstall.sh
after-install: systemd/scripts/postinstall.sh
before-upgrade: systemd/scripts/preupgrade.sh
after-upgrade: systemd/scripts/postupgrade.sh
before-remove: systemd/scripts/preremove.sh
after-remove: systemd/scripts/postremove.sh
after-purge: systemd/scripts/purge.sh
user: pufferpanel
group: pufferpanel
files: |
build-artifacts/pufferpanel:/usr/sbin/pufferpanel
build-artifacts/www:/var/www/pufferpanel
build-artifacts/email:/etc/pufferpanel/email
config.linux.json:/etc/pufferpanel/config.json
systemd/servicefiles/pufferpanel.service:/lib/systemd/system/pufferpanel.service
RPMBUILD/var/lib/pufferpanel:/var/lib/pufferpanel
RPMBUILD/var/log/pufferpanel:/var/log/pufferpanel
config: |
/etc/pufferpanel/email/*
/etc/pufferpanel/config.json:noreplace
suggested-packages: |
jre-1.8.0-headless
jre-11-headless
glibc.i686
libstdc++.i686
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: pufferpanel_${{ env.VERSION }}_linux_amd64
path: build-artifacts/
- name: Publish Artifacts
uses: actions/upload-artifact@v1
with:
name: pufferpanel_${{ env.VERSION }}_amd64.deb
path: pufferpanel_${{ env.VERSION }}_amd64.deb
- name: Publish Artifacts
uses: actions/upload-artifact@v1
with:
name: pufferpanel-${{ env.VERSION }}-1.x86_64.rpm
path: ${{ steps.rpmamd64.outputs.file }}
build-linux-arm64-binaries:
name: Build Binaries - Linux ARM64
runs-on: ubuntu-20.04
needs: ['build-shared']
timeout-minutes: 10
steps:
- name: Get the version
run: echo "VERSION=0.0.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^${{ env.GO_VERSION }}
- uses: actions/download-artifact@v3
with:
name: pufferpanel_build_artifact
- name: Download APT packages
run: |
sudo apt-get update
sudo apt-get install --download-only -y gcc-aarch64-linux-gnu
- name: APT Install
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Restore Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Build ARM64
run: |
go build -o build-artifacts/pufferpanel -ldflags "-X 'github.com/pufferpanel/pufferpanel/v2.Hash=${{ github.sha }}' -X 'github.com/pufferpanel/pufferpanel/v2.Version=${{ env.VERSION }}'" -v github.com/pufferpanel/pufferpanel/v2/cmd
env:
GOOS: linux
GOARCH: arm64
CC: aarch64-linux-gnu-gcc
CGO_ENABLED: 1
- name: Set up build folder
run: |
mkdir -p DEBBUILD/usr/sbin DEBBUILD/var/www/pufferpanel DEBBUILD/var/lib/pufferpanel
mkdir -p DEBBUILD/var/log/pufferpanel DEBBUILD/etc/pufferpanel DEBBUILD/lib/systemd/system/
mkdir -p DEBBUILD/var/lib/pufferpanel/binaries
cp config.linux.json DEBBUILD/etc/pufferpanel/config.json
cp build-artifacts/pufferpanel DEBBUILD/usr/sbin/pufferpanel
cp -r build-artifacts/www/* DEBBUILD/var/www/pufferpanel
cp -r build-artifacts/email DEBBUILD/etc/pufferpanel
cp systemd/servicefiles/pufferpanel.service DEBBUILD/lib/systemd/system/pufferpanel.service
- name: Build Package DEB ARM64
id: debarm64
uses: pufferpanel/build-deb@master
with:
data-folder: DEBBUILD
package: pufferpanel
version: ${{ env.VERSION }}
license: Apache 2.0
architecture: arm64
maintainer: PufferPanel <[email protected]>
homepage: https://pufferpanel.com
description: Game management server panel
before-install: systemd/scripts/preinstall.sh
after-install: systemd/scripts/postinstall.sh
before-upgrade: systemd/scripts/preupgrade.sh
after-upgrade: systemd/scripts/postupgrade.sh
before-remove: systemd/scripts/preremove.sh
after-remove: systemd/scripts/postremove.sh
after-purge: systemd/scripts/purge.sh
user: pufferpanel
group: pufferpanel
suggested-packages: |
java-runtime-headless
lib32gcc1
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: pufferpanel_${{ env.VERSION }}_linux_arm64
path: build-artifacts
- name: Publish Artifacts
uses: actions/upload-artifact@v1
with:
name: pufferpanel_${{ env.VERSION }}_arm64.deb
path: pufferpanel_${{ env.VERSION }}_arm64.deb
build-docker-image-base:
runs-on: ubuntu-20.04
name: "Build Docker images"
if: "startsWith(github.ref, 'refs/tags/v') || !(contains(github.event.head_commit.message, '[skip]') || startsWith(github.head_ref, 'l10n_master'))"
env:
REPO: karyeet/pufferpanel
VERSION: latest
strategy:
matrix:
platform: ["linux/amd64","linux/arm64"]
# timeout-minutes: 25
steps:
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "TAG=$REPO:base-devel" >> $GITHUB_ENV
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "VERSION=devel" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "TAG=$REPO:base-${GITHUB_REF/refs\/tags\/v/},$REPO:base" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build base container
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.TAG }}
build-args: |
sha: ${{ github.sha }}
version: ${{ env.VERSION }}
platforms: ${{ matrix.platform }}
build-docker-image-master:
runs-on: ubuntu-20.04
name: "Build Docker massive images"
needs: [ "build-docker-image-base" ]
env:
REPO: karyeet/pufferpanel
VERSION: base
timeout-minutes: 5
strategy:
matrix:
platform: [ "linux/amd64" ]
steps:
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "TAG=$REPO:devel" >> $GITHUB_ENV
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "VERSION=devel" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "TAG=$REPO:${GITHUB_REF/refs\/tags\/v/},$REPO:latest" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v3
with:
context: dockerfiles/massive
push: true
tags: ${{ env.TAG }}
build-args: |
sha: ${{ github.sha }}
version: ${{ env.VERSION }}
DOCKER_TAG: base-${{ env.VERSION }}
platforms: ${{ matrix.platform }}
build-docker-image-children:
runs-on: ubuntu-20.04
name: "Build Docker child images"
needs: ["build-docker-image-base"]
env:
REPO: karyeet/pufferpanel
VERSION: devel
timeout-minutes: 5
strategy:
matrix:
variant: ["java", "java8", "java17", "nodejs", "srcds"]
platform: ["linux/amd64"]
steps:
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "TAG=$REPO:${{ matrix.variant }}-devel" >> $GITHUB_ENV
- name: Get the version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run:
echo "VERSION=devel" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "TAG=$REPO:${{ matrix.variant }}-${GITHUB_REF/refs\/tags\/v/},$REPO:${{ matrix.variant }}" >> $GITHUB_ENV
- name: Get the version
if: startsWith(github.ref, 'refs/tags/v')
run:
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v3
with:
context: dockerfiles/${{ matrix.variant }}
push: true
tags: ${{ env.TAG }}
build-args: |
sha: ${{ github.sha }}
version: ${{ env.VERSION }}
DOCKER_TAG: base-${{ env.VERSION }}
platforms: ${{ matrix.platform }}