From b54831042123ca4a7b6a16cffdcdba25be008a4e Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Tue, 22 Dec 2020 00:13:24 +0100 Subject: [PATCH] github workflows --- .github/workflows/build-test.yml | 36 +++++++++++++ .github/workflows/release.yml | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..24dd0c7 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,36 @@ +name: Go + +on: + push: + branches: + - "*" + pull_request: + branches: [ master ] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + + - name: Install gox + run: | + go get github.com/mitchellh/gox + + - name: Build + run: gox -osarch="linux/amd64 linux/arm darwin/amd64 windows/amd64" + + - name: Test + run: go test -v ./... + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5b54361 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Go + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + + - name: Install gox + run: | + go get github.com/mitchellh/gox + + - name: Build + run: gox -osarch="linux/amd64 linux/arm darwin/amd64 windows/amd64" + + - name: Test + run: go test -v ./... + + - 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 x64 + id: upload-linux-x64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.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: ./koolnova2mqtt_linux_amd64 + asset_name: koolnova2mqtt_linux_amd64 + asset_content_type: application/octet-stream + - name: Upload Linux arm + id: upload-linux-arm + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.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: ./koolnova2mqtt_linux_arm + asset_name: koolnova2mqtt_linux_arm + asset_content_type: application/octet-stream + - name: Upload Mac + id: upload-mac + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.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: ./koolnova2mqtt_darwin_amd64 + asset_name: koolnova2mqtt_mac + asset_content_type: application/octet-stream + - name: Upload Windows x64 + id: upload-windows-x64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.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: ./koolnova2mqtt_windows_amd64.exe + asset_name: koolnova2mqtt_windows_amd64.exe + asset_content_type: application/octet-stream