github workflows

This commit is contained in:
Javier Peletier
2020-12-22 00:13:24 +01:00
committed by Javier Peletier
parent 6415adea4c
commit 34aea318ba
2 changed files with 122 additions and 0 deletions

36
.github/workflows/build-test.yml vendored Normal file
View File

@@ -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 ./...

86
.github/workflows/release.yml vendored Normal file
View File

@@ -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