Skip to content

release

release #74

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: release
on:
workflow_dispatch:
schedule:
- cron: "00 23 * * *"
jobs:
build:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get last sing-box tags
id: getsb
uses: actions/github-script@v7
with:
script: |
const sbLatestRelease = await github.rest.repos.getLatestRelease({
owner: 'SagerNet',
repo: 'sing-box',
});
core.setOutput("singbox_tag", sbLatestRelease.data.tag_name);
- name: prepare enviroment
run: |
sudo apt update
sudo apt install jq -y
- name: download resources
id: download
env:
IP_CONF_LINK: ${{ secrets.SB_IP_CFG }}
SITE_CONF_LINK: ${{ secrets.SB_SITE_CFG }}
run: |
wget -O 'geosite.db' 'https://github.com/simplerick-simplefun/sing-geosite/releases/latest/download/geosite.db'
wget -O 'geoip.db' 'https://github.com/simplerick-simplefun/sing-geoip/releases/latest/download/geoip.db'
if [ "${IP_CONF_LINK}" == '' ] || [ "${IP_CONF_LINK}" == 'null' ] || [ "${SITE_CONF_LINK}" == '' ] || [ "${SITE_CONF_LINK}" == 'null' ]; then
echo "ip_conf_file='./config/dest_ip_sets.json'" >> "$GITHUB_OUTPUT"
echo "site_conf_filee='./config/dest_site_sets.json'" >> "$GITHUB_OUTPUT"
else
echo "ip_conf_file=$(curl -s -J -O -w '%{filename_effective}' ${IP_CONF_LINK})" >> "$GITHUB_OUTPUT"
echo "site_conf_file=$(curl -s -J -O -w '%{filename_effective}' ${SITE_CONF_LINK})" >> "$GITHUB_OUTPUT"
fi
- name: build
id: build
run: |
echo "tag=$(date +'%Y%m%d%H%M')" >> "$GITHUB_OUTPUT"
ip_conf=${{ steps.download.outputs.ip_conf_file }}
site_conf=${{ steps.download.outputs.site_conf_file }}
bash build.sh "$ip_conf" "$site_conf"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-build-artifacts
path: |
*.srs
- name: Push artifacts to release branch
if: steps.build.outcome == 'success'
run: |
mkdir dist
cp *.srs dist/
git config --local user.email "${{ vars.OWNER_EMAIL }}"
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 *.srs
git commit -am "Updated at $(date)"
git branch -D release
git branch -m release
git remote add myrepo "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git tag "${{ steps.build.outputs.tag }}"
git push myrepo "${{ steps.build.outputs.tag }}"
git push -f -u myrepo release
- name: Purge CDN Cache
if: steps.build.outcome == 'success'
run: |
curl -L "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/" > /dev/null 2>&1
- name: Release
if: steps.build.outcome == 'success'
id: release
uses: softprops/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
append_body: false
fail_on_unmatched_files: true
name: "${{ steps.build.outputs.tag }}"
tag_name: "${{ steps.build.outputs.tag }}"
files: |
./*.srs