This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
Release #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
jobs: | |
release: | |
strategy: | |
matrix: | |
os: [ubuntu-20.04-16core, windows-latest, mac-woind] | |
runs-on: ${{ matrix.os }} | |
name: Release | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.0-rc.1' | |
go-version-file: go.mod | |
check-latest: true | |
- name: Install dependencies on Ubuntu | |
if: matrix.os == 'ubuntu-20.04-16core' | |
run: | | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 | |
sudo apt-add-repository https://cli.github.com/packages | |
sudo apt-get update | |
sudo apt-get install gh | |
gh --version | |
- name: Install dependencies on Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
choco install gh | |
gh --version | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.PAL_PAT }} | |
- name: Generate binary on Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
$AppName = "pal" | |
$GithubUsername = "<username>" | |
$GithubRepo = "<repo>" | |
$Version = git describe --tags --abbrev=0 | |
$OutputDir = "build" | |
Remove-Item -Recurse -Force $OutputDir -ErrorAction SilentlyContinue | |
New-Item -ItemType Directory -Path $OutputDir | Out-Null | |
& go build -o "$OutputDir\$AppName-arm64.exe" -tags netgo -ldflags "-s -w" -pkgdir $env:GOPATH/pkg/windows_amd64/netgo | |
& go build -o "$OutputDir\$AppName-amd64.exe" -tags netgo -ldflags "-s -w" -pkgdir $env:GOPATH/pkg/windows_amd64/netgo | |
cd $OutputDir | |
Compress-Archive -Path "$AppName-amd64.exe" -DestinationPath "$AppName-$Version-win-amd64.zip" | |
Compress-Archive -Path "$AppName-arm64.exe" -DestinationPath "$AppName-$Version-win-arm64.zip" | |
ls | |
cd .. | |
gh auth login --with-token < ${GITHUB_TOKEN} | |
gh release create $Version "$OutputDir\$AppName-$Version-win-amd64.zip" -t "Release $Version amd64" | |
gh release create $Version "$OutputDir\$AppName-$Version-win-arm64.zip" -t "Release $Version arm64" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAL_PAT }} | |
- name: Generate binary on Ubuntu | |
if: matrix.os == 'ubuntu-20.04-16core' | |
run: | | |
APP_NAME="pal" | |
VERSION=$(git describe --tags --abbrev=0) | |
OUTPUT_DIR="build" | |
GITHUB_USERNAME="<username>" | |
GITHUB_REPO="<repo>" | |
rm -rf $OUTPUT_DIR | |
mkdir -p $OUTPUT_DIR | |
env GOARCH=arm64 GOOS=linux go build -ldflags="-s -w" -o $OUTPUT_DIR/$APP_NAME-linux-arm64 | |
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o $OUTPUT_DIR/$APP_NAME-linux-amd64 | |
cd $OUTPUT_DIR | |
zip $APP_NAME-$VERSION-linux-amd64.zip $APP_NAME-linux-amd64 | |
zip $APP_NAME-$VERSION-linux-arm64.zip $APP_NAME-linux-amd64 | |
ls -lart | |
cd .. | |
gh auth login --with-token < ${GITHUB_TOKEN} | |
gh release create $VERSION $OUTPUT_DIR/$APP_NAME-$VERSION-linux-amd64.zip -t "Release $VERSION amd64" | |
gh release create $VERSION $OUTPUT_DIR/$APP_NAME-$VERSION-linux-arm64.zip -t "Release $VERSION arm64" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAL_PAT }} | |
- name: Generate binary on Mac | |
if: matrix.os == 'macos-latest' | |
run: | | |
APP_NAME="pal" | |
VERSION=$(git describe --tags --abbrev=0) | |
OUTPUT_DIR="build" | |
GITHUB_USERNAME="<username>" | |
GITHUB_REPO="<repo>" | |
rm -rf $OUTPUT_DIR | |
mkdir -p $OUTPUT_DIR | |
env GOARCH=arm64 GOOS=darwin go build -ldflags="-s -w" -o $OUTPUT_DIR/$APP_NAME-darwin-arm64 | |
env GOARCH=amd64 GOOS=darwin go build -ldflags="-s -w" -o $OUTPUT_DIR/$APP_NAME-darwin-amd64 | |
cd $OUTPUT_DIR | |
zip $APP_NAME-$VERSION-darwin-amd64.zip $APP_NAME-darwin-amd64 | |
zip $APP_NAME-$VERSION-darwin-arm64.zip $APP_NAME-darwin-amd64 | |
ls -lart | |
cd .. | |
gh auth login --with-token < ${GITHUB_TOKEN} | |
gh release create $VERSION $OUTPUT_DIR/$APP_NAME-$VERSION-darwin-amd64.zip -t "Release $VERSION amd64" | |
gh release create $VERSION $OUTPUT_DIR/$APP_NAME-$VERSION-darwin-arm64.zip -t "Release $VERSION arm64" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAL_PAT }} |