-
Notifications
You must be signed in to change notification settings - Fork 0
chore: GitHub Actions release workflow for homecli (WH-3686) #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danielBWeka
merged 6 commits into
release/v0.4
from
danielb/release-homecli-workflow-WH-3686
Feb 1, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| name: release-homecli | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Release version (e.g., 0.4.25)" | ||
| required: true | ||
| type: string | ||
| branch: | ||
| description: "Release branch" | ||
| required: true | ||
| type: choice | ||
| default: release/v0.4 | ||
| options: | ||
| - release/v0.4 | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| permissions: | ||
| contents: write # to create tags and github releases | ||
|
|
||
| steps: | ||
| - name: Validate version format | ||
| env: | ||
| VERSION: ${{ github.event.inputs.version }} | ||
| run: | | ||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::Version must be in format X.Y.Z (e.g., 0.4.25)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Checkout release branch | ||
| uses: actions/checkout@v4.1.1 | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| with: | ||
| ref: ${{ github.event.inputs.branch }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check if tag already exists | ||
| env: | ||
| VERSION: ${{ github.event.inputs.version }} | ||
| run: | | ||
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | ||
| echo "::error::Tag v$VERSION already exists. Please use a different version." | ||
| exit 1 | ||
| fi | ||
| echo "Tag v$VERSION does not exist, proceeding with release." | ||
|
|
||
| - name: Setup Golang | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache-dependency-path: go.sum | ||
|
|
||
| - name: Build binaries | ||
| env: | ||
| VERSION: ${{ github.event.inputs.version }} | ||
| run: | | ||
| chmod +x ./build.sh | ||
| ./build.sh "$VERSION" | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981 | ||
| with: | ||
| tag_name: "v${{ github.event.inputs.version }}" | ||
| name: "v${{ github.event.inputs.version }}" | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| target_commitish: ${{ github.event.inputs.branch }} | ||
| draft: false | ||
| generate_release_notes: true | ||
| files: | | ||
| bin/homecli_linux_amd64 | ||
| bin/homecli_darwin_amd64 | ||
This file contains hidden or 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,20 +1,70 @@ | ||
| #!/usr/bin/env sh | ||
|
|
||
| set -e # Exit on any error | ||
|
|
||
| BUILD_VERSION=$1 | ||
| BUILD_TIME=$(date +'%Y-%m-%d_%T') | ||
|
|
||
| echo "Building homecli version: ${BUILD_VERSION:-<no version specified>}" | ||
|
|
||
| LD_FLAGS="-X main.BuildVersion=$BUILD_VERSION -X main.BuildTime=$BUILD_TIME" | ||
| LD_FLAGS="$LD_FLAGS -s -w" | ||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LD_FLAGS" -o bin/homecli_linux_amd64 cmd/homecli/*.go | ||
| CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$LD_FLAGS" -o bin/homecli_darwin_amd64 cmd/homecli/*.go | ||
|
|
||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Add UPX compression | ||
| echo "Building Linux amd64 binary..." | ||
| if ! CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LD_FLAGS" -o bin/homecli_linux_amd64 cmd/homecli/*.go; then | ||
| echo "::error::Failed to build Linux binary" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Building macOS amd64 binary..." | ||
| if ! CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$LD_FLAGS" -o bin/homecli_darwin_amd64 cmd/homecli/*.go; then | ||
| echo "::error::Failed to build macOS binary" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Add UPX compression (only on Linux, only for Linux binary) | ||
| # UPX doesn't support macOS binaries and the Linux UPX binary can't run on macOS | ||
|
|
||
| if [ "$(uname)" = "Linux" ]; then | ||
| echo "Compressing Linux binary with UPX..." | ||
| UPX_VERSION="${UPX_VERSION:-4.2.2}" | ||
| UPX_PLATFORM="${UPX_PLATFORM:-amd64_linux}" | ||
| # SHA256 checksum verified from official UPX 4.2.2 release | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| UPX_SHA256="915c8e844f835de03b9cc311ff185aedec79d757aee9d7133a528b9e89c463bb" | ||
|
|
||
| UPX_ARCHIVE="upx-${UPX_VERSION}-${UPX_PLATFORM}.tar.xz" | ||
|
|
||
| if [ ! -d "upx-${UPX_VERSION}-${UPX_PLATFORM}" ]; then | ||
| echo "Downloading UPX ${UPX_VERSION}..." | ||
| if ! wget -q "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/${UPX_ARCHIVE}"; then | ||
| echo "::error::Failed to download UPX" | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Verifying UPX checksum..." | ||
| ACTUAL_SHA256=$(sha256sum "$UPX_ARCHIVE" | cut -d' ' -f1) | ||
| if [ "$ACTUAL_SHA256" != "$UPX_SHA256" ]; then | ||
| echo "::error::UPX checksum verification failed!" | ||
| echo "Expected: $UPX_SHA256" | ||
| echo "Actual: $ACTUAL_SHA256" | ||
| rm -f "$UPX_ARCHIVE" | ||
| exit 1 | ||
| fi | ||
| echo "Checksum verified." | ||
|
|
||
| UPX_VERSION="${UPX_VERSION:-4.2.2}" | ||
| UPX_PLATFORM="${UPX_PLATFORM:-amd64_linux}" | ||
| if ! tar xf "$UPX_ARCHIVE" "upx-${UPX_VERSION}-${UPX_PLATFORM}/upx"; then | ||
| echo "::error::Failed to extract UPX" | ||
| exit 1 | ||
| fi | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
danielBWeka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if [ ! -d "upx-${UPX_VERSION}-${UPX_PLATFORM}" ]; then | ||
| wget "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${UPX_PLATFORM}.tar.xz" | ||
| tar xf "upx-${UPX_VERSION}-${UPX_PLATFORM}.tar.xz" "upx-${UPX_VERSION}-${UPX_PLATFORM}/upx" | ||
| if ! "upx-${UPX_VERSION}-${UPX_PLATFORM}/upx" bin/homecli_linux_amd64; then | ||
| echo "::error::Failed to compress Linux binary with UPX" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Skipping UPX compression (not running on Linux)" | ||
| fi | ||
|
|
||
| "upx-${UPX_VERSION}-${UPX_PLATFORM}/upx" bin/* | ||
| echo "" | ||
| echo "Build completed successfully!" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.