feat: Optimize the logic of the download page #17
Workflow file for this run
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*' | |
env: | |
# Necessary for most environments as build failure can occur due to OOM issues | |
NODE_OPTIONS: "--max-old-space-size=4096" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23.4' # 使用你的 Go 版本 | |
- name: Download dependencies | |
run: | | |
go mod download | |
go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
grep -qxF "deb http://gb.archive.ubuntu.com/ubuntu jammy main" /etc/apt/sources.list || echo "deb http://gb.archive.ubuntu.com/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list | |
sudo apt update | |
sudo apt install libgtk-3-dev | |
sudo apt install libwebkit2gtk-4.0-dev | |
cd frontend && npm install | |
- name: Get version info | |
id: get_version | |
run: | | |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Update version file | |
run: | | |
cat > internal/version/version.go << EOL | |
package version | |
var ( | |
Version = "${{ steps.get_version.outputs.VERSION }}" | |
Commit = "${{ steps.get_version.outputs.COMMIT }}" | |
Date = "${{ steps.get_version.outputs.DATE }}" | |
) | |
EOL | |
- name: Build executables | |
env: | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
COMMIT: ${{ steps.get_version.outputs.COMMIT }} | |
DATE: ${{ steps.get_version.outputs.DATE }} | |
run: | | |
wails build -clean -platform=windows,linux -ldflags="-X 'fy-novel/internal/version.Version=$VERSION' -X 'fy-novel/internal/version.Commit=$COMMIT' -X 'fy-novel/internal/version.Date=$DATE'" | |
- name: Compress executables | |
run: | | |
cd build/bin && zip -r ../../fynovel-amd64.zip . && cd ../.. | |
cd build/bin && tar -czvf ../../fynovel-amd64.tar.gz . && cd ../.. | |
- name: Generate a changelog | |
uses: orhun/git-cliff-action@v3 | |
id: git-cliff | |
with: | |
config: cliff.toml | |
args: --verbose --tag ${{ steps.get_version.outputs.VERSION }} | |
env: | |
OUTPUT: CHANGELOG.md | |
GITHUB_REPO: ${{ github.repository }} | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "*.zip,*.tar.gz" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: ${{ steps.git-cliff.outputs.content }} |