Release #797
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: | |
schedule: | |
- cron: "30 22 * * *" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get latest go version | |
id: version | |
run: | | |
echo ::set-output name=go_version::1.19.9 | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ steps.version.outputs.go_version }} | |
- name: Build geosite | |
id: build | |
run: | | |
go run -v . | |
- name: Generate sha256 hash | |
if: steps.build.outputs.skip != 'true' | |
run: | | |
mkdir dist | |
cp geosite.db dist/ | |
sha256sum geosite.db > dist/geosite.db.sha256sum | |
- name: Push artifacts to release branch | |
if: steps.build.outputs.skip != 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-action[bot]" | |
git fetch | |
git checkout release | |
git checkout --orphan release-orphan | |
git rm -rf . | |
cp dist/* . | |
git add geosite.db | |
git add geosite.db.sha256sum | |
git commit -am "Updated at $(date)" | |
git branch -D release | |
git branch -m release | |
- name: GitHub Push | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: release | |
force: true | |
- name: Purge CDN Cache | |
run: | | |
curl -L https://purge.jsdelivr.net/gh/soffchen/sing-geosite@release/geosite.db > /dev/null 2>&1 | |
curl -L https://purge.jsdelivr.net/gh/soffchen/sing-geosite@release/geosite.db.sha256sum > /dev/null 2>&1 | |
- name: Create a release | |
if: steps.build.outputs.skip != 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.build.outputs.tag }} | |
release_name: ${{ steps.build.outputs.tag }} | |
draft: false | |
prerelease: false | |
- name: Release geosite.db | |
if: steps.build.outputs.skip != 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./geosite.db | |
asset_name: geosite.db | |
asset_content_type: application/octet-stream | |
- name: Release geosite.db sha256sum | |
if: steps.build.outputs.skip != 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./geosite.db.sha256sum | |
asset_name: geosite.db.sha256sum | |
asset_content_type: text/plain |