Skip to content

Beta15

Beta15 #19

Workflow file for this run

name: Cross Compile Go Project
on:
pull_request:
types: [opened, synchronize]
push:
tags:
- '*'
jobs:
build:
name: Build on ${{ matrix.os }} for ${{ matrix.goarch }}
runs-on: ${{ if matrix.os == 'linux' }}ubuntu-latest${{ else }}${{ matrix.os }}-latest${{ endif }}

Check failure on line 13 in .github/workflows/cross_compile.yml

View workflow run for this annotation

GitHub Actions / Cross Compile Go Project

Invalid workflow file

The workflow is not valid. .github/workflows/cross_compile.yml (Line: 13, Col: 14): Unrecognized named-value: 'if'. Located at position 1 within expression: if matrix.os == 'linux'
strategy:
matrix:
include:
- os: linux
goarch: amd64
- os: linux
goarch: arm64
- os: darwin
goarch: amd64
- os: darwin
goarch: arm64
- os: windows
goarch: amd64
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21.1' # Set to specific Go version.
- name: Install build dependencies (macOS)
if: matrix.os == 'darwin'
run: |
brew update
brew install sqlite3
- name: Install build dependencies (Ubuntu)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libc6-dev libsqlite3-dev
- name: Install build dependencies (Windows)
if: matrix.os == 'windows'
run: |
choco install msys2 --params "/NoUpdate /InstallDir:C:\msys64" --no-progress -y
C:\msys64\usr\bin\bash -lc "pacman -Syu --noconfirm"
C:\msys64\usr\bin\bash -lc "pacman -S --noconfirm mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cmake mingw-w64-x86_64-extra-cmake-modules mingw-w64-x86_64-toolchain"
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "CC=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV
echo "CXX=x86_64-w64-mingw32-g++" >> $GITHUB_ENV
- name: Create output directory
run: mkdir -p output
- name: Compile Go for target
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
run: |
if [ "$GOOS" = "windows" ]; then
go build -o output/gensokyo-hunyuan-${{ matrix.os }}-${{ matrix.goarch }}.exe
else
go build -o output/gensokyo-hunyuan-${{ matrix.os }}-${{ matrix.goarch }}
fi
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: gensokyo-hunyuan-${{ matrix.os }}-${{ matrix.goarch }}
path: output/gensokyo-hunyuan-${{ matrix.os }}-${{ matrix.goarch }}${{ endsWith(matrix.os, 'windows') && '.exe' || '' }}
prepare_release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: output
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
- name: Upload Release Assets
run: |
for dir in output/*; do
if [ -d "$dir" ]; then
for file in "$dir"/*; do
if [ -f "$file" ]; then
asset_name=$(basename "$file")
echo "Uploading ${asset_name}"
GITHUB_UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}
GITHUB_UPLOAD_URL="${GITHUB_UPLOAD_URL%\{*}"
GITHUB_UPLOAD_URL="${GITHUB_UPLOAD_URL%\?*}"
curl \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"${file}" \
"${GITHUB_UPLOAD_URL}?name=${asset_name}&label=${asset_name}"
else
echo "Expected a file in ${dir}, but found something else."
fi
done
else
echo "Expected ${dir} to be a directory."
fi
done