Skip to content

Update push.yml

Update push.yml #64

Workflow file for this run

name: Golang build and release
on:
push:
tags:
- 'v*'
pull_request:
workflow_dispatch:
inputs:
tag_name:
description: 'Release Tag'
required: true
default: 'v0.0.0'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, 'dev') }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
go: ["1.21.6"]
goos: [linux, windows]
goarch: [amd64, arm64]
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Setup Go environment
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
# Download dependencies
- name: Download Go modules
env:
CGO_ENABLED: 0
run: |
go mod download
# Build the binaries
- name: Build binaries
env:
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
run: |
go build -o dist/PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}
chmod 755 dist/*
# Verify build output
- name: Verify build output
run: |
if [ ! -f "dist/PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}" ]; then
echo "Build output is missing!"
exit 1
fi
echo "Build completed successfully."
# Append .EXE to Windows binary
- name: Append .EXE to windows binary
run: |
if [ "${{ matrix.goos }}" == "windows" ]; then
cd dist/
mv PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }} PalworldServerConfigParser-${{ matrix.goos }}-${{ matrix.goarch }}.exe
cd ..
fi
# Upload dist folder as an artifact
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
generate-checksum:
name: Generate checksum file
runs-on: ubuntu-22.04
needs: build
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Download the dist artifact from the build job
- name: Download dist artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
# Generate checksum.txt
- name: Generate checksum.txt
run: |
cd dist
sha256sum * > checksum.txt
cd ..
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
# Upload all artifacts to GitHub release
- name: Upload release artifacts
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ steps.generate-token.outputs.token }}
file: dist/*
tag: ${{ github.ref_name || inputs.tag_name }}
overwrite: false
file_glob: true