-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
8 changed files
with
395 additions
and
210 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,115 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- 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: Set env | ||
run: | | ||
echo '::set-env name=GO111MODULE::on' | ||
# Release tag comes from the github reference. | ||
RELEASE_TAG=$(echo ${GITHUB_REF} | sed -e 's!.*/!!') | ||
echo "::set-env name=RELEASE_TAG::${RELEASE_TAG}" | ||
echo "::set-output name=RELEASE_TAG::${RELEASE_TAG}" | ||
# Ensure the release tag has expected format. | ||
echo ${RELEASE_TAG} | grep -q '^v' || exit 1 | ||
# Release version is same as release tag without leading 'v'. | ||
RELEASE_VERSION=$(echo ${GITHUB_REF} | sed -e 's!.*/v!!') | ||
echo "::set-env name=RELEASE_VERSION::${RELEASE_VERSION}" | ||
echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}" | ||
- name: Build | ||
run: go build -v -ldflags="-X github.com/attestantio/dirk/cmd.ReleaseVersion=${RELEASE_VERSION}" . | ||
|
||
- name: Test | ||
run: go test -v . | ||
|
||
- name: Fetch xgo | ||
run: | | ||
go get github.com/suburbandad/xgo | ||
- name: Cross-compile | ||
run: xgo -v -x -ldflags="-X github.com/attestantio/dirk/cmd.ReleaseVersion=${RELEASE_VERSION}" --targets="linux/amd64,linux/arm64,windows/amd64" github.com/attestantio/dirk | ||
|
||
- name: Create windows zip file | ||
run: | | ||
mv dirk-windows-4.0-amd64.exe dirk.exe | ||
zip --junk-paths dirk-${RELEASE_VERSION}-windows-exe.zip dirk.exe | ||
- name: Create linux AMD64 tgz file | ||
run: | | ||
mv dirk-linux-amd64 dirk | ||
tar zcf dirk-${RELEASE_VERSION}-linux-amd64.tar.gz dirk | ||
- name: Create linux ARM64 tgz file | ||
run: | | ||
mv dirk-linux-arm64 dirk | ||
tar zcf dirk-${RELEASE_VERSION}-linux-arm64.tar.gz dirk | ||
- 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 ${{ env.RELEASE_VERSION }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload windows zip file | ||
id: upload-release-asset-windows | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./dirk-${{ env.RELEASE_VERSION }}-windows-exe.zip | ||
asset_name: dirk-${{ env.RELEASE_VERSION }}-windows-exe.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload linux AMD64 tgz file | ||
id: upload-release-asset-linux-amd64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./dirk-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz | ||
asset_name: dirk-${{ env.RELEASE_VERSION }}-linux-amd64.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload linux ARM64 tgz file | ||
id: upload-release-asset-linux-arm64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./dirk-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz | ||
asset_name: dirk-${{ env.RELEASE_VERSION }}-linux-arm64.tar.gz | ||
asset_content_type: application/gzip |
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
Oops, something went wrong.