Release #227
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: | |
workflow_dispatch: | |
workflow_run: | |
workflows: [ Test, Dependabot ] | |
types: | |
- completed | |
jobs: | |
release: | |
if: | | |
github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' && | |
(github.event.workflow_run.name == 'Test' && github.event.workflow_run.head_branch == 'main' || | |
github.event.workflow_run.name == 'Dependabot') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: stable | |
- name: Delete Old Release | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let release | |
try { | |
release = await github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: 'v1.0' | |
}) | |
} catch(e) { | |
console.error(e) | |
return | |
} | |
await github.rest.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release.data.id | |
}) | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'tags/v1.0' | |
}) | |
- name: Build and Pack | |
id: build | |
run: | | |
make pack | |
echo "date=$(TZ=PRC date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v1.0 | |
name: ${{ steps.build.outputs.date }} | |
body: ${{ steps.build.outputs.date }} | |
files: release* |