2022-05-01 17:14:30 +00:00
|
|
|
name: Prerelease
|
2022-05-01 16:59:41 +00:00
|
|
|
on:
|
2022-11-26 12:11:43 +00:00
|
|
|
workflow_dispatch:
|
2022-05-01 16:59:41 +00:00
|
|
|
push:
|
|
|
|
branches:
|
2022-05-01 17:14:30 +00:00
|
|
|
- Alpha
|
2022-05-01 16:59:41 +00:00
|
|
|
- Beta
|
|
|
|
pull_request:
|
|
|
|
branches:
|
2022-05-01 17:14:30 +00:00
|
|
|
- Alpha
|
2022-05-01 16:59:41 +00:00
|
|
|
- Beta
|
|
|
|
jobs:
|
2023-01-15 07:04:27 +00:00
|
|
|
Build-Prerelease-WithoutCGO:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version: '1.19'
|
|
|
|
check-latest: true
|
|
|
|
|
|
|
|
- name: Cache go module
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-WithoutCGO-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-WithoutCGO-
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
if: ${{github.ref_name=='Beta'}}
|
|
|
|
run: |
|
|
|
|
go test ./...
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
if: success()
|
|
|
|
env:
|
|
|
|
NAME: Clash.Meta
|
|
|
|
BINDIR: bin
|
|
|
|
run: make -j$(($(nproc) + 1)) releases
|
|
|
|
|
|
|
|
- name: Delete current release assets
|
|
|
|
uses: andreaswilli/delete-release-assets-action@v2.0.0
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
tag: Prerelease-${{ github.ref_name }}
|
|
|
|
deleteOnlyFromDrafts: false
|
|
|
|
|
|
|
|
Build-Prerelease-WithCGO:
|
2023-01-14 17:46:30 +00:00
|
|
|
permissions: write-all
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
|
2022-05-01 16:59:41 +00:00
|
|
|
steps:
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2023-01-14 17:46:30 +00:00
|
|
|
- name: Set variables
|
2023-01-15 07:04:27 +00:00
|
|
|
if: ${{github.ref_name=='Alpha'}}
|
|
|
|
run: echo "VERSION=alpha" >> $GITHUB_ENV
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Set variables
|
|
|
|
if: ${{github.ref_name=='Beta'}}
|
|
|
|
run: echo "VERSION=beta" >> $GITHUB_ENV
|
2023-01-14 17:46:30 +00:00
|
|
|
shell: bash
|
|
|
|
|
2023-01-15 07:04:27 +00:00
|
|
|
- name: Set ENV
|
|
|
|
run: |
|
|
|
|
echo "NAME=clash.meta" >> $GITHUB_ENV
|
|
|
|
echo "BUILD_TIME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
|
|
|
echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
|
|
|
|
echo "ShortSHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
|
|
|
|
echo "$ShortSHA"
|
|
|
|
echo "$REPO"
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version: '1.19'
|
|
|
|
check-latest: true
|
|
|
|
|
|
|
|
- name: Set up xgo
|
|
|
|
run: |
|
|
|
|
docker pull techknowlogick/xgo:latest
|
|
|
|
go install src.techknowlogick.com/xgo@latest
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
if: success()
|
|
|
|
env:
|
|
|
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
|
|
|
run: |
|
|
|
|
mkdir bin
|
|
|
|
cp .github/release-cgo.sh ./bin/
|
|
|
|
cp .github/rename-cgo.sh ./bin/
|
|
|
|
cd bin
|
|
|
|
ls -la
|
|
|
|
chmod +x *
|
|
|
|
bash ./release-cgo.sh
|
|
|
|
rm ./release-cgo.sh
|
|
|
|
bash ./rename-cgo.sh
|
|
|
|
rm ./rename-cgo.sh
|
|
|
|
ls -la
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: ${{ success() }}
|
|
|
|
with:
|
|
|
|
name: artifact
|
|
|
|
path: bin/
|
|
|
|
|
|
|
|
Build-Prerelease-WithCGO-Android:
|
|
|
|
permissions: write-all
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2023-01-14 17:46:30 +00:00
|
|
|
- name: Set variables
|
2023-01-15 07:04:27 +00:00
|
|
|
if: ${{github.ref_name=='Alpha'}}
|
2023-01-14 17:46:30 +00:00
|
|
|
run: echo "VERSION=alpha" >> $GITHUB_ENV
|
|
|
|
shell: bash
|
|
|
|
|
2023-01-15 07:04:27 +00:00
|
|
|
- name: Set variables
|
|
|
|
if: ${{github.ref_name=='Beta'}}
|
|
|
|
run: echo "VERSION=beta" >> $GITHUB_ENV
|
|
|
|
shell: bash
|
|
|
|
|
2023-01-14 17:46:30 +00:00
|
|
|
- name: Set ENV
|
|
|
|
run: |
|
|
|
|
echo "NAME=clash.meta" >> $GITHUB_ENV
|
|
|
|
echo "BUILD_TIME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
|
|
|
echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
|
|
|
|
echo "ShortSHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
|
|
|
|
echo "$ShortSHA"
|
|
|
|
echo "$REPO"
|
|
|
|
shell: bash
|
|
|
|
|
2022-11-02 14:13:54 +00:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
2022-05-01 16:59:41 +00:00
|
|
|
with:
|
2022-11-02 14:13:54 +00:00
|
|
|
go-version: '1.19'
|
|
|
|
check-latest: true
|
2023-01-15 07:04:27 +00:00
|
|
|
|
|
|
|
- name: Cache go module
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-WithCGO-Android-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-WithCGO-Android-
|
|
|
|
${{ runner.os }}-go-
|
2022-05-01 17:14:30 +00:00
|
|
|
|
2023-01-14 17:46:30 +00:00
|
|
|
- uses: nttld/setup-ndk@v1
|
|
|
|
id: setup-ndk
|
|
|
|
with:
|
|
|
|
ndk-version: r25b
|
|
|
|
add-to-path: false
|
|
|
|
|
2022-05-01 16:59:41 +00:00
|
|
|
- name: Build
|
|
|
|
if: success()
|
|
|
|
env:
|
2023-01-14 17:46:30 +00:00
|
|
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
|
|
|
run: |
|
|
|
|
mkdir bin
|
2023-01-15 07:04:27 +00:00
|
|
|
cp .github/release-cgo-android.sh ./
|
|
|
|
bash ./release-cgo-android.sh
|
|
|
|
rm ./release-cgo-android.sh
|
|
|
|
cp .github/rename-cgo.sh ./bin/
|
2023-01-14 17:46:30 +00:00
|
|
|
cd bin
|
|
|
|
ls -la
|
|
|
|
chmod +x *
|
2023-01-15 07:04:27 +00:00
|
|
|
bash ./rename-cgo.sh
|
|
|
|
rm ./rename-cgo.sh
|
2023-01-14 17:46:30 +00:00
|
|
|
ls -la
|
|
|
|
cd ..
|
2022-05-01 16:59:41 +00:00
|
|
|
|
2023-01-15 07:04:27 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: ${{ success() }}
|
2022-05-01 16:59:41 +00:00
|
|
|
with:
|
2023-01-15 07:04:27 +00:00
|
|
|
name: artifact
|
|
|
|
path: bin/
|
|
|
|
|
|
|
|
Upload-Prerelease:
|
|
|
|
needs: [ Build-Prerelease-WithoutCGO, Build-Prerelease-WithCGO, Build-Prerelease-WithCGO-Android ]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: artifact
|
|
|
|
path: bin/
|
|
|
|
|
|
|
|
- name: Display structure of downloaded files
|
|
|
|
run: ls -R
|
|
|
|
working-directory: bin
|
2022-05-01 16:59:41 +00:00
|
|
|
|
|
|
|
- name: Tag Repo
|
2023-01-10 16:50:04 +00:00
|
|
|
uses: richardsimko/update-tag@v1
|
2022-05-01 16:59:41 +00:00
|
|
|
with:
|
2022-05-02 00:27:17 +00:00
|
|
|
tag_name: Prerelease-${{ github.ref_name }}
|
2022-05-01 16:59:41 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Upload Alpha
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
if: ${{ success() }}
|
|
|
|
with:
|
2023-01-10 16:50:04 +00:00
|
|
|
tag: ${{ github.ref_name }}
|
2022-05-02 00:27:17 +00:00
|
|
|
tag_name: Prerelease-${{ github.ref_name }}
|
2022-05-01 16:59:41 +00:00
|
|
|
files: bin/*
|
|
|
|
prerelease: true
|
|
|
|
generate_release_notes: true
|