-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a18971
commit db9e3e9
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
jobs: | ||
release: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
id: create_release | ||
|
||
- run: echo "${{ steps.create_release.outputs.upload_url }}" > upload_url.txt | ||
|
||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: upload_url | ||
path: upload_url.txt | ||
|
||
build: | ||
strategy: | ||
matrix: | ||
target: | ||
- os: 'windows-latest' | ||
goos: 'windows' | ||
goarch: 'amd64' | ||
ext: '.exe' | ||
go: [ '1.14' ] | ||
|
||
runs-on: ${{ matrix.target.os }} | ||
|
||
needs: [ release ] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- run: | | ||
git rev-parse --short HEAD | Tee-Object -Variable VERSION | ||
Get-Date -format yyyyMMdd.HHmmss | Tee-Object -Variable DATE | ||
go build -v -ldflags "-X github.com/jamesmoriarty/gohack.Version=$VERSION -X github.com/jamesmoriarty/gohack.Date=$DATE" -o ${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ matrix.target.ext }} cmd/gohack.go | ||
env: | ||
GOOS: ${{ matrix.target.goos }} | ||
GOARCH: ${{ matrix.target.goarch }} | ||
CGO_ENABLED: 1 | ||
- uses: actions/download-artifact@v1 | ||
with: | ||
name: upload_url | ||
|
||
- id: get_release_info | ||
run: | | ||
echo "##[set-output name=upload_url;]$(cat upload_url/upload_url.txt)" | ||
env: | ||
TAG_REF_NAME: ${{ github.ref }} | ||
REPOSITORY_NAME: ${{ github.repository }} | ||
|
||
- uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.get_release_info.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ./${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ matrix.target.ext }} | ||
asset_name: ${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ matrix.target.ext }} | ||
asset_content_type: application/zip |