forked from dim13/hashcolor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test support for multiplatform builds
- Loading branch information
Showing
2 changed files
with
68 additions
and
45 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
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 |
---|---|---|
@@ -1,82 +1,103 @@ | ||
name: Release | ||
name: Create a draft Release | ||
|
||
on: | ||
push: | ||
tags: [ "v*" ] | ||
|
||
jobs: | ||
build: | ||
name: Build Release | ||
create: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
go-version: ^1.14 | ||
id: go | ||
tag_name: ${{ github.ref }} | ||
release_name: Hashcolor ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
|
||
build: | ||
name: Build Release binaries | ||
runs-on: ubuntu-latest | ||
needs: create | ||
strategy: | ||
matrix: | ||
goos: [linux, darwin] | ||
goarch: [amd64, arm64] | ||
|
||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
||
- name: Set up Go 1.x | ||
id: go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
go mod download | ||
go mod verify | ||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
||
- name: Build | ||
- name: Build Golang binaries (${{ matrix.goos }}/${{ matrix.goarch }}) | ||
id: build_binary | ||
env: | ||
CGO_ENABLED: 0 | ||
GOOS: "${{ matrix.goos }}" | ||
GOARCH: "${{ matrix.goarch }}" | ||
run: | | ||
export CGO_ENABLED=0 | ||
go build -ldflags "-s -w -X main.Version=${{ steps.get_version.outputs.VERSION }}" \ | ||
-trimpath -o ./hashcolor \ | ||
./cmd/hashcolor/main.go | ||
- name: Package | ||
- name: Package (${{ matrix.goos }}/${{ matrix.goarch }}) | ||
env: | ||
CGO_ENABLED: 0 | ||
GOOS: "${{ matrix.goos }}" | ||
GOARCH: "${{ matrix.goarch }}" | ||
VERSION: "${{ steps.get_version.outputs.VERSION }}" | ||
run: | | ||
mkdir -p "./build/hashcolor-${{ steps.get_version.outputs.VERSION }}" | ||
cp -av --target-directory="./build/hashcolor-${{ steps.get_version.outputs.VERSION }}" \ | ||
mkdir -p "./build/hashcolor-${VERSION}" | ||
cp -av --target-directory="./build/hashcolor-${VERSION}" \ | ||
./examples ./hashcolor ./LICENSE ./README.md | ||
cd "./build/hashcolor-${{ steps.get_version.outputs.VERSION }}" | ||
cd "./build/hashcolor-${VERSION}" | ||
find . -type f -exec sha256sum "{}" + > checksums.lst | ||
cd .. | ||
tar cvzf "./hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz" \ | ||
"./hashcolor-${{ steps.get_version.outputs.VERSION }}" | ||
sha256sum "./hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz" > \ | ||
"./hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz.sha256" | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Hashcolor ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
tar cvzf "./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz" \ | ||
"./hashcolor-${VERSION}" | ||
sha256sum "./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz" > \ | ||
"./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz.sha256" | ||
- name: Upload Release Tarball | ||
- name: Upload Release Tarball (${{ matrix.goos }}/${{ matrix.goarch }}) | ||
id: upload-release-tarball | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz | ||
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz | ||
upload_url: ${{ needs.create.outputs.upload_url }} | ||
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload Release Digest | ||
- name: Upload Release Digest (${{ matrix.goos }}/${{ matrix.goarch }}) | ||
id: upload-release-digest | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz.sha256 | ||
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tar.gz.sha256 | ||
upload_url: ${{ needs.create.outputs.upload_url }} | ||
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz.sha256 | ||
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz.sha256 | ||
asset_content_type: text/plain |