mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
name: Release
|
|
on: [push]
|
|
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')
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v2
|
|
#with:
|
|
# go-version: ${{ steps.version.outputs.go_version }}
|
|
with:
|
|
go-version: 1.18.0-rc1
|
|
stable: false
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Cache go module
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Get dependencies, run test
|
|
run: |
|
|
go test ./...
|
|
|
|
- name: SSH connection to Actions
|
|
uses: P3TERX/ssh2actions@v1.0.0
|
|
if: github.actor == github.repository_owner && contains(github.event.head_commit.message, '[ssh]')
|
|
|
|
- name: Build
|
|
#if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
NAME: clash
|
|
BINDIR: bin
|
|
run: make -j releases
|
|
|
|
- name: Prepare upload
|
|
run: |
|
|
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
|
|
with:
|
|
name: clash_${{ env.FILE_SHA }}${{ env.FILE_DATE }}
|
|
path: |
|
|
bin/*
|
|
|
|
- name: Upload Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: bin/*
|
|
draft: true
|
|
|
|
- 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
|
|
delete_tag_pattern: tun
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|