Clash.Meta/.github/workflows/release.yml

113 lines
4.1 KiB
YAML
Raw Normal View History

2021-10-11 20:08:18 +08:00
name: Release
2021-07-01 22:49:29 +08:00
on: [push]
2019-08-15 11:40:40 +08:00
jobs:
build:
runs-on: ubuntu-latest
steps:
- 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')
2019-10-14 10:40:00 +08:00
- name: Setup Go
2020-06-04 10:38:30 +08:00
uses: actions/setup-go@v2
2019-08-15 11:40:40 +08:00
with:
go-version: ${{ steps.version.outputs.go_version }}
2019-08-15 11:40:40 +08:00
- name: Check out code into the Go module directory
2020-06-04 10:38:30 +08:00
uses: actions/checkout@v2
2019-11-06 12:05:18 +08:00
- name: Cache go module
2020-06-04 10:38:30 +08:00
uses: actions/cache@v2
2019-11-06 12:05:18 +08:00
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
2019-08-15 11:40:40 +08:00
2021-10-11 20:08:18 +08:00
- name: Get dependencies, run test
2019-08-15 11:40:40 +08:00
run: |
2021-10-27 23:10:11 +08:00
# install python3.9
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt install -y python3.9 python3.9-dev
2021-10-21 20:22:23 +08:00
# fetch python cross compile source files
mkdir -p bin/python/
cd bin/python/
curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-darwin-amd64.tar.xz
curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-darwin-arm64.tar.xz
curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-windows-amd64.tar.xz
curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-windows-386.tar.xz
2021-10-27 23:10:11 +08:00
#curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-linux-amd64.tar.xz
#curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-linux-arm64.tar.xz
2021-10-21 20:22:23 +08:00
#curl -LO https://raw.githubusercontent.com/yaling888/snack/main/python-3.9.7-linux-386.tar.xz
tar -Jxf python-3.9.7-darwin-amd64.tar.xz
tar -Jxf python-3.9.7-darwin-arm64.tar.xz
tar -Jxf python-3.9.7-windows-amd64.tar.xz
tar -Jxf python-3.9.7-windows-386.tar.xz
2021-10-27 23:10:11 +08:00
#tar -Jxf python-3.9.7-linux-amd64.tar.xz
#tar -Jxf python-3.9.7-linux-arm64.tar.xz
2021-10-21 20:22:23 +08:00
#tar -Jxf python-3.9.7-linux-386.tar.xz
rm python-3.9.7-*.tar.xz
cd ../../
2021-10-27 23:10:11 +08:00
# go test
go test -tags build_local ./...
2019-10-14 10:40:00 +08:00
# init xgo
docker pull techknowlogick/xgo:latest
go install src.techknowlogick.com/xgo@latest
2021-09-08 22:36:54 +08:00
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
if: github.actor == github.repository_owner && contains(github.event.head_commit.message, '[ssh]')
2021-10-21 20:22:23 +08:00
env:
SSH_PASSWORD: ${{ secrets.ADAWADLHIOH }}
2021-09-08 22:36:54 +08:00
2019-10-14 10:40:00 +08:00
- name: Build
2021-07-01 22:49:29 +08:00
#if: startsWith(github.ref, 'refs/tags/')
2019-10-14 10:40:00 +08:00
env:
NAME: clash
BINDIR: bin
run: |
2021-10-21 20:22:23 +08:00
make -j releases
2021-10-27 23:10:11 +08:00
#ls -lahF bin/python/
2019-10-14 10:40:00 +08:00
2021-07-01 22:49:29 +08:00
- name: Prepare upload
if: startsWith(github.ref, 'refs/tags/') == false
2021-07-01 22:49:29 +08:00
run: |
2021-10-21 20:22:23 +08:00
rm -rf bin/python/
2021-07-01 22:49:29 +08:00
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "FILE_SHA=$(git describe --tags --always 2>/dev/null)" >> $GITHUB_ENV
- name: Upload files to Artifacts
uses: actions/upload-artifact@v2
if: startsWith(github.ref, 'refs/tags/') == false
2021-07-01 22:49:29 +08:00
with:
name: clash_${{ env.FILE_SHA }}${{ env.FILE_DATE }}
path: |
bin/*
2019-10-14 10:40:00 +08:00
- name: Upload Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/*
draft: true
2021-07-01 22:49:29 +08:00
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 2
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.2.0
if: startsWith(github.ref, 'refs/tags/') && !cancelled()
with:
keep_latest: 1
delete_tags: true
2021-10-21 20:22:23 +08:00
delete_tag_pattern: plus-pro
2021-07-01 22:49:29 +08:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}