Release #997
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 0 * * *" | |
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::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ steps.version.outputs.go_version }} | |
- name: Build geoip | |
id: build | |
run: go run -v . | |
- name: Generate sha256 hash | |
if: steps.build.outputs.skip != 'true' | |
run: | | |
mkdir dist | |
sha256sum geoip.db > dist/geoip.db.sha256sum | |
sha256sum geoip-cn.db > dist/geoip-cn.db.sha256sum | |
cp geoip.db* dist/ | |
cp geoip-cn.db* dist/ | |
- 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 geoip.db | |
git add geoip-cn.db | |
git add geoip.db.sha256sum | |
git add geoip-cn.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-geoip@release/geoip.db > /dev/null 2>&1 | |
curl -L https://purge.jsdelivr.net/gh/soffchen/sing-geoip@release/geoip-cn.db > /dev/null 2>&1 | |
curl -L https://purge.jsdelivr.net/gh/soffchen/sing-geoip@release/geoip.db.sha256sum > /dev/null 2>&1 | |
curl -L https://purge.jsdelivr.net/gh/soffchen/sing-geoip@release/geoip-cn.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 geoip.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: ./geoip.db | |
asset_name: geoip.db | |
asset_content_type: application/octet-stream | |
- name: Release geoip.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: ./geoip.db.sha256sum | |
asset_name: geoip.db.sha256sum | |
asset_content_type: text/plain | |
- name: Release geoip-cn.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: ./geoip-cn.db | |
asset_name: geoip-cn.db | |
asset_content_type: application/octet-stream | |
- name: Release geoip.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: ./geoip-cn.db.sha256sum | |
asset_name: geoip-cn.db.sha256sum | |
asset_content_type: text/plain |