Skip to content

修复 release

修复 release #2

Workflow file for this run

name: Go Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Generate changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Build releases
run: |
APP_NAME="gitea-pages"
# 创建输出目录
mkdir -p dist
GOOS=linux GOARCH=amd64 go build -o "dist/${APP_NAME}-linux-amd64" ./
GOOS=linux GOARCH=386 go build -o "dist/${APP_NAME}-linux-i386" ./
GOOS=linux GOARCH=arm64 go build -o "dist/${APP_NAME}-linux-arm64" ./
GOOS=linux GOARCH=loongarch64 go build -o "dist/${APP_NAME}-linux-loongarch64" ./
GOOS=darwin GOARCH=amd64 go build -o "dist/${APP_NAME}-darwin-amd64" ./
GOOS=darwin GOARCH=arm64 go build -o "dist/${APP_NAME}-darwin-arm64" ./
GOOS=windows GOARCH=amd64 go build -o "dist/${APP_NAME}-windows-amd64.exe" ./
cd dist
for file in *; do
zip "${file}.zip" "$file"
done
ls *.zip > assets.txt
cd ..
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
- name: Upload all release assets
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
while IFS= read -r asset; do
echo "Uploading $asset"
gh release upload ${{ github.ref_name }} ./dist/$asset --clobber
done < ./dist/assets.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}