Skip to content

nightly-release

nightly-release #394

Workflow file for this run

name: nightly-release
on:
schedule:
# 每天 UTC 时间 00:00 自动触发构建
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
create-nightly-release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 确保获取所有历史和标签
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Get latest version and create nightly tag
id: get_version
run: |
# 获取最新的非 nightly 版本标签
latest_version=$(git describe --tags --abbrev=0 --exclude="*-next")
# 增加补丁版本号
nightly_version=$(echo $latest_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
# 创建 nightly 标签
nightly_tag="${nightly_version}-next"
echo "NIGHTLY_TAG=${nightly_tag}" >> $GITHUB_OUTPUT
# 删除远程的旧 nightly tag(如果存在)
git push origin :refs/tags/*-next || true
# 删除本地的旧 nightly tag(如果存在)
git tag -d $(git tag -l '*-next') || true
# 创建新的 nightly tag
git tag $nightly_tag
# 强制推送新的 nightly tag
git push origin $nightly_tag --force
- name: Delete Old GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NIGHTLY_TAG: ${{ steps.get_version.outputs.NIGHTLY_TAG }}
run: |
gh release delete $NIGHTLY_TAG --yes || true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Get dependencies
run: go mod download
- name: GoReleaser Action
uses: goreleaser/goreleaser-action@v5
with:
version: v1.26.2
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.get_version.outputs.NIGHTLY_TAG }}