From 95d5c87609087b8a49cd21b2865a5b669cd29ab2 Mon Sep 17 00:00:00 2001 From: befovy <51129600+befovy@users.noreply.github.com> Date: Thu, 25 Jun 2020 13:08:29 +0800 Subject: [PATCH] ci: release and publish assets when push tags (#14) * ci: add release and upload asset * ci: update go check branches * ci: format release.yml --- .github/workflows/go.yml | 11 +++- .github/workflows/release.yml | 105 ++++++++++++++++++++++++++++++++++ .gitignore | 3 +- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f1e8675..757463a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,5 +1,14 @@ name: Go -on: [push, pull_request] +on: + push: + branches: + - master + - main + - develop + pull_request: + branches: + - main + - master jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a72a2da --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +name: Release +on: + push: + tags: + - 'v*' + +jobs: + + build: + name: Build and Upload Release + runs-on: macos-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Test + run: go test -v github.com/befovy/fvm/... + + - name: Build for Linux + run: | + env GOOS=linux GOARCH=amd64 go build -v . + zip -j fvm-linux-amd64.zip fvm + + - name: Build for Mac OS + run: | + env GOOS=darwin GOARCH=amd64 go build -v . + zip -j fvm-macos-amd64.zip fvm + + - name: Build for Windows + run: | + env GOOS=windows GOARCH=amd64 go build -v . + zip -j fvm-windows-amd64.zip fvm.exe + env GOOS=windows GOARCH=386 go build -v . + zip -j fvm-windows-386.zip fvm.exe + + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Linux Release Asset + id: upload-linux-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./fvm-linux-amd64.zip + asset_name: fvm-linux-amd64.zip + asset_content_type: application/zip + + - name: Upload Mac OS Release Asset + id: upload-macos-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./fvm-macos-amd64.zip + asset_name: fvm-macos-amd64.zip + asset_content_type: application/zip + + - name: Upload Windows amd64 Release Asset + id: upload-windows-amd64-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./fvm-windows-amd64.zip + asset_name: fvm-windows-amd64.zip + asset_content_type: application/zip + + - name: Upload Windows x86 Release Asset + id: upload-windows-386-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./fvm-windows-386.zip + asset_name: fvm-windows-386.zip + asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index f3b6fc4..81fe9db 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ fvm.iml .DS_Store # binary -fvm \ No newline at end of file +fvm +fvm.exe