合并拉取请求 #80 #49
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: Auto Release | |
on: | |
push: | |
tags: | |
- 'release-v*' | |
env: | |
APP_NAME: free-gpt3.5-2api | |
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: 'stable' | |
check-latest: true | |
- name: Build Binary | |
run: | | |
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${{ env.APP_NAME }} -a -ldflags '-s -w -extldflags "-static"' . && rm -rf artifact && mkdir -p artifact && cp ${{ env.APP_NAME }} artifact/${{ env.APP_NAME }} && cd artifact && tar -czvf ../${{ env.APP_NAME }}-linux-amd64.tar.gz * && cd .. | |
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ${{ env.APP_NAME }} -a -ldflags '-s -w -extldflags "-static"' . && rm -rf artifact && mkdir -p artifact && cp ${{ env.APP_NAME }} artifact/${{ env.APP_NAME }} && cd artifact && tar -czvf ../${{ env.APP_NAME }}-darwin-amd64.tar.gz * && cd .. | |
GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0 go build -o ${{ env.APP_NAME }} -a -ldflags '-s -w -extldflags "-static"' . && rm -rf artifact && mkdir -p artifact && cp ${{ env.APP_NAME }} artifact/${{ env.APP_NAME }} && cd artifact && tar -czvf ../${{ env.APP_NAME }}-freebsd-amd64.tar.gz * && cd .. | |
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ${{ env.APP_NAME }} -a -ldflags '-s -w -extldflags "-static"' . && rm -rf artifact && mkdir -p artifact && cp ${{ env.APP_NAME }} artifact/${{ env.APP_NAME }}.exe && cd artifact && tar -czvf ../${{ env.APP_NAME }}-windows-amd64.tar.gz * && cd .. | |
- name: Upload Artifact | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.APP_NAME }}-pre-built.zip | |
path: | | |
${{ env.APP_NAME }}-windows-amd64.tar.gz | |
${{ env.APP_NAME }}-linux-amd64.tar.gz | |
${{ env.APP_NAME }}-darwin-amd64.tar.gz | |
${{ env.APP_NAME }}-freebsd-amd64.tar.gz | |
- name: Get Release Name | |
shell: bash | |
id: grn | |
run: echo "tag=$(echo $GITHUB_REF | sed 's|refs/tags/||')" >> $GITHUB_OUTPUT | |
- name: Generate Changelog | |
id: changelog | |
run: | | |
export PATH=$PATH:$HOME/go/bin | |
go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest | |
git-chglog -o CHANGELOG.md ${{ steps.grn.outputs.tag }} | |
- name: Release | |
id: release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
# GITHUB_TOKEN | |
GITHUB_TOKEN: ${{ secrets.GB_TOKEN }} | |
with: | |
# tag_name: 使用 tag | |
tag_name: ${{ github.ref }} | |
# release_name: 使用 tag | |
name: ${{ steps.grn.outputs.tag }} | |
# body: 使用 changelog | |
body_path: CHANGELOG.md | |
# 草稿 | |
draft: false | |
# 预发布 | |
prerelease: false | |
# 自动生成 release notes | |
generate_release_notes: true | |
# 上传文件 | |
files: | | |
${{ env.APP_NAME }}-linux-amd64.tar.gz | |
${{ env.APP_NAME }}-windows-amd64.tar.gz | |
${{ env.APP_NAME }}-darwin-amd64.tar.gz | |
${{ env.APP_NAME }}-freebsd-amd64.tar.gz | |
- name: Delete Workflow Runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ secrets.GB_TOKEN }} | |
repository: ${{ github.repository }} | |
retain_days: 1 | |
keep_minimum_runs: 8 |