Skip to content

Commit

Permalink
Github publish binary (#20)
Browse files Browse the repository at this point in the history
* Github publish binary

* Test build on CI

* Add version

* Show binary / size

* adjust

* name

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
  • Loading branch information
pvizeli and ludeeus authored Apr 9, 2021
1 parent 6a3e32c commit 239cdf6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
version-resolver:
default: minor
template: |
## What's Changed
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build

on:
release:
types: ["published"]
pull_request:
branches: ["main"]

env:
GOLANG_VERSION: "1.15"
BINARY_NAME: "os-agent-debian-amd64.bin"

jobs:
build_debian:
name: Build amd64 debian
runs-on: ubuntu-latest
container: buildpack-deps:buster
steps:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Setup go ${{ env.GOLANG_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOLANG_VERSION }}

- name: Build binary
run: |
version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}')
go build -ldflags="-s -w -X main.version=${version}" -o "${{ env.BINARY_NAME }}"
du -hs os-agent-debian-amd64.bin
- name: Upload release asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "${{ github.workspace }}/${{ env.BINARY_NAME }}"
asset_name: ${{ env.BINARY_NAME }}
asset_content_type: application/x-binary

- name: Signing asset
if: github.event_name == 'release'
uses: home-assistant/actions/helpers/codenotary@master
with:
source: "${{ github.workspace }}/${{ env.BINARY_NAME }}"
user: ${{ secrets.VCN_USER }}
password: ${{ secrets.VCN_PASSWORD }}
organisation: ${{ secrets.VCN_ORG }}
29 changes: 2 additions & 27 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,14 @@ name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
name: Release Drafter
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Find Next Version
id: version
run: |
declare -i newpost
latest=$(git describe --tags $(git rev-list --tags --max-count=1))
latestpre=$(echo "$latest" | awk '{split($0,a,"."); print a[1] "." a[2]}')
datepre=$(date --utc '+%Y.%m')
if [[ "$latestpre" == "$datepre" ]]; then
latestpost=$(echo "$latest" | awk '{split($0,a,"."); print a[3]}')
newpost=$latestpost+1
else
newpost=0
fi
echo Current version: $latest
echo New target version: $datepre.$newpost
echo "::set-output name=version::$datepre.$newpost"
- name: Run Release Drafter
uses: release-drafter/release-drafter@v5
with:
tag: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 239cdf6

Please sign in to comment.