name: Release on: push: branches: - rm 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 }} - name: Check out code into the Go module directory uses: actions/checkout@v3 - name: Go cache paths id: go-cache-paths run: | echo "::set-output name=go-build::$(go env GOCACHE)" echo "::set-output name=go-mod::$(go env GOMODCACHE)" - name: Cache go module uses: actions/cache@v2 with: path: | ${{ steps.go-cache-paths.outputs.go-mod }} ${{ steps.go-cache-paths.outputs.go-build }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Setup Python uses: actions/setup-python@v2 with: python-version: '3.9' - name: Get dependencies, run test run: | # 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 #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 #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 #tar -Jxf python-3.9.7-linux-amd64.tar.xz #tar -Jxf python-3.9.7-linux-arm64.tar.xz #tar -Jxf python-3.9.7-linux-386.tar.xz rm python-3.9.7-*.tar.xz cd ../../ # go test go test -tags build_local ./... # init xgo docker pull techknowlogick/xgo:latest go install src.techknowlogick.com/xgo@latest - name: Build #if: startsWith(github.ref, 'refs/tags/') env: NAME: clash BINDIR: bin run: | make -j releases #ls -lahF bin/python/ - name: Prepare upload if: startsWith(github.ref, 'refs/tags/') == false run: | rm -rf bin/python/ 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 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 prerelease: true generate_release_notes: 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: plus-pro env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}