|
| 1 | +# https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context |
| 2 | +# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif |
| 3 | +# https://github.community/t/how-to-get-just-the-tag-name/16241/10 |
| 4 | + |
| 5 | +name: github_release |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - "v*" |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: cancel previous runs |
| 18 | + uses: styfle/cancel-workflow-action@0.6.0 |
| 19 | + with: |
| 20 | + access_token: ${{ github.token }} |
| 21 | + |
| 22 | + - name: source info |
| 23 | + id: source_info |
| 24 | + run: | |
| 25 | + echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} |
| 26 | + echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} |
| 27 | + echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} |
| 28 | +
|
| 29 | + - uses: actions/setup-go@v2 |
| 30 | + with: |
| 31 | + stable: 'false' |
| 32 | + go-version: '1.15.7' |
| 33 | + |
| 34 | + - uses: actions/checkout@v2 |
| 35 | + |
| 36 | + - name: build_release_assets |
| 37 | + run: | |
| 38 | + mkdir -p bin_release |
| 39 | + GOPATH="" CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "-extldflags '-static' -X main.AppVersion=$SOURCE_TAG" -o bin_release/freenas-iscsi-provisioner_linux-amd64 |
| 40 | + GOPATH="" CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -ldflags "-extldflags '-static' -X main.AppVersion=$SOURCE_TAG" -o bin_release/freenas-iscsi-provisioner_linux-arm |
| 41 | + GOPATH="" CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -ldflags "-extldflags '-static' -X main.AppVersion=$SOURCE_TAG" -o bin_release/freenas-iscsi-provisioner_linux-arm64 |
| 42 | + GOPATH="" CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -ldflags "-extldflags '-static' -X main.AppVersion=$SOURCE_TAG" -o bin_release/freenas-iscsi-provisioner_darwin-amd64 |
| 43 | + GOPATH="" CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -a -ldflags "-extldflags '-static' -X main.AppVersion=$SOURCE_TAG" -o bin_release/freenas-iscsi-provisioner_freebsd-amd64 |
| 44 | +
|
| 45 | + - name: create release |
| 46 | + id: create_release |
| 47 | + if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 48 | + uses: actions/create-release@v1 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + with: |
| 52 | + tag_name: ${{ github.ref }} |
| 53 | + release_name: ${{ github.ref }} |
| 54 | + draft: false |
| 55 | + prerelease: false |
| 56 | + |
| 57 | + - name: upload release assets |
| 58 | + id: upload-release-assets |
| 59 | + uses: alexellis/upload-assets@0.2.2 |
| 60 | + env: |
| 61 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + with: |
| 63 | + asset_paths: '["./bin_release/freenas-iscsi-provisioner_*"]' |
| 64 | + |
0 commit comments