Skip to content

Commit

Permalink
Automatically release obs-installer binaries with incremental semve…
Browse files Browse the repository at this point in the history
…r autotagging. (#319)

Automatic release semver obs-installer binary
  • Loading branch information
vulkoingim authored Sep 20, 2022
1 parent 6b1a56d commit 38c307d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
branches:
- main

env:
golang-version: "1.19"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# https://github.com/PaulHatch/semantic-version
- id: semver
uses: paulhatch/semantic-version@v4
with:
# The prefix to use to identify tags
tag_prefix: "v"
# A string which, if present in a git commit, indicates that a change represents a
# major (breaking) change, supports regular expressions wrapped with '/'
major_pattern: "(MAJOR)"
# Same as above except indicating a minor change, supports regular expressions wrapped with '/'
minor_pattern: "(MINOR)"
# A string to determine the format of the version output
format: "${major}.${minor}.${patch}-prerelease${increment}"
# Optional path to check for changes. If any changes are detected in the path the
# 'changed' output will true. Enter multiple paths separated by spaces.
change_path: "installer/"
# If this is set to true, *every* commit will be treated as a new version.
bump_each_commit: false
- uses: actions/setup-go@v2
if: ${{steps.semver.outputs.changed}}
with:
go-version: ${{ env.golang-version }}
- name: Build artifacts
if: ${{steps.semver.outputs.changed}}
run: VERSION=${{steps.semver.outputs.version_tag}} ./hack/build-obs-installer.sh
# https://github.com/softprops/action-gh-release
- uses: softprops/action-gh-release@v1
if: ${{steps.semver.outputs.changed}}
with:
tag_name: ${{steps.semver.outputs.version_tag}}
generate_release_notes: true
fail_on_unmatched_files: true
files: ./installer/*.tar.gz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ diff
!monitoring-satellite/manifests/probers/*
!monitoring-satellite/manifests/kube-prometheus-rules/*
!monitoring-satellite/manifests/crds/*

*.tar.gz
33 changes: 33 additions & 0 deletions hack/build-obs-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# shellcheck disable=SC2034

set -euo pipefail

SCRIPT_PATH=$(realpath "$(dirname "$0")")
PROJECT_ROOT=$(realpath "${SCRIPT_PATH}/../")

INSTALLER_DIR="${PROJECT_ROOT}/installer"
BINARY_NAME="obs-installer"

if [ -z ${VERSION+x} ]; then
echo "Must supply VERSION"
fi

pushd "${INSTALLER_DIR}"

for GOOS in darwin linux; do
for GOARCH in arm64 amd64; do
export GOOS=$GOOS
export GOARCH=$GOARCH

RELEASE_NAME="${BINARY_NAME}_${VERSION}_${GOOS}_${GOARCH}.tar.gz"
echo "Building ${RELEASE_NAME}"

go build -o ${BINARY_NAME} .
tar cf "${RELEASE_NAME}" ${BINARY_NAME}
rm "${BINARY_NAME}"
done
done

popd

0 comments on commit 38c307d

Please sign in to comment.