Release #1530
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: "5 18 * * *" | |
# label: | |
# types: [created, deleted] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "release" | |
release: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
ref: 'latest-release' | |
path: './oldrelease' | |
fetch-depth: 0 | |
- name: Set some variables | |
run: | | |
echo "RELEASE_NAME=$(TZ='Asia/Taipei' date --rfc-3339=seconds) [""$(curl -sSL --fail --retry 5 --retry-delay 10 --retry-max-time 60 -H 'Accept: application/vnd.github.v3+json' \ | |
'https://api.github.com/repos/IceCodeNew/go-collection/commits?per_page=1&sha=release' | | |
grep -Fm1 'sha' | cut -d'"' -f4)""]" >> $GITHUB_ENV | |
echo "BRANCH_NAME=$(TZ='Asia/Taipei' date +%F-%H-%M-%S-%Z)" >> $GITHUB_ENV | |
shell: bash | |
- name: Move files to publish directory | |
run: | | |
pushd oldrelease || exit 1 | |
while [[ $(wc -l < ./releases.txt) -ge 15 ]]; do | |
git push -d origin "$(head -n 1 ./releases.txt)" | |
sed -i '1d' ./releases.txt | |
done | |
echo "$BRANCH_NAME" >> ./releases.txt | |
popd | |
mkdir -p ./publish/usr/share/caddy/ | |
cp -f ./oldrelease/releases.txt ./publish/ | |
cp -f ./oldrelease/usr/share/caddy/index.html ./publish/usr/share/caddy/index.html | |
docker create -it --name dummy quay.io/icecodenew/go-collection:latest bash | |
docker cp dummy:/go/bin/ ./publish/assets | |
docker rm -f dummy | |
docker rmi -f quay.io/icecodenew/go-collection:latest | |
zstd -6 -T0 -o "./publish/assets/caddy.zst" "./publish/assets/caddy-with-cfdns-l4" && | |
rm -f "./publish/assets/caddy-with-cfdns-l4" | |
zstd -6 -T0 -o "./publish/assets/caddy.exe.zst" "./publish/assets/caddy-with-cfdns-l4.exe" && | |
rm -f "./publish/assets/caddy-with-cfdns-l4.exe" | |
# curl -sSLRfq --retry 5 --retry-delay 10 --retry-max-time 60 --compressed -o './publish/assets/v2ray-plugin' \ | |
# -- "https://github.com/IceCodeNew/v2ray-plugin/releases/latest/download/v2ray-plugin_linux_amd64" | |
- name: Git push assets to "latest-release" branch | |
run: | | |
cd publish || exit 1 | |
git init | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -b "$BRANCH_NAME" | |
git add -A | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add go-collection "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f go-collection HEAD:latest-release | |
git push -f go-collection HEAD:"$BRANCH_NAME" | |
- name: Purge jsdelivr CDN | |
run: | | |
cd publish || exit 1 | |
for file in $(ls); do | |
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@latest-release/${file}" | |
done |