name: Prerelease on: workflow_dispatch: push: branches: - Alpha - Beta pull_request: branches: - Alpha - Beta jobs: 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: permissions: write-all runs-on: ubuntu-22.04 steps: - name: Check out code into the Go module directory uses: actions/checkout@v3 - name: Set variables 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 shell: bash - 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 - name: Set variables 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 shell: bash - 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: 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- - uses: nttld/setup-ndk@v1 id: setup-ndk with: ndk-version: r25b add-to-path: false - name: Build if: success() env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} run: | mkdir bin cp .github/release-cgo-android.sh ./ bash ./release-cgo-android.sh rm ./release-cgo-android.sh cp .github/rename-cgo.sh ./bin/ cd bin ls -la chmod +x * bash ./rename-cgo.sh rm ./rename-cgo.sh ls -la cd .. - uses: actions/upload-artifact@v3 if: ${{ success() }} with: 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 - name: Tag Repo uses: richardsimko/update-tag@v1 with: tag_name: Prerelease-${{ github.ref_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload Alpha uses: softprops/action-gh-release@v1 if: ${{ success() }} with: tag: ${{ github.ref_name }} tag_name: Prerelease-${{ github.ref_name }} files: bin/* prerelease: true generate_release_notes: true