Release jfcm #6
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
name: Release jfvm to Homebrew | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to release (e.g. v2.0.0)' | |
required: true | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.24' | |
- name: Determine tag to release | |
id: tag | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "Detected manual run" | |
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | |
else | |
echo "Detected tag push" | |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
fi | |
- name: Build binaries for all platforms | |
run: | | |
mkdir -p dist | |
# Build for macOS AMD64 | |
GOOS=darwin GOARCH=amd64 go build -o dist/jfvm-darwin-amd64 . | |
# Build for macOS ARM64 | |
GOOS=darwin GOARCH=arm64 go build -o dist/jfvm-darwin-arm64 . | |
# Build for Linux AMD64 | |
GOOS=linux GOARCH=amd64 go build -o dist/jfvm-linux-amd64 . | |
# Build for Linux ARM64 | |
GOOS=linux GOARCH=arm64 go build -o dist/jfvm-linux-arm64 . | |
# Make all binaries executable | |
chmod +x dist/jfvm-* | |
- name: Test binaries | |
run: | | |
echo "Testing built binaries..." | |
./dist/jfvm-darwin-amd64 --version | |
./dist/jfvm-darwin-arm64 --version | |
./dist/jfvm-linux-amd64 --version | |
./dist/jfvm-linux-arm64 --version | |
- name: Upload GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.tag.outputs.tag }} | |
name: "jfvm ${{ steps.tag.outputs.tag }}" | |
body: | | |
## What's New | |
This release includes: | |
- Multi-platform support (macOS ARM64/AMD64, Linux ARM64/AMD64) | |
- JFrog CLI version management | |
- Homebrew integration | |
## Downloads | |
Platform-specific binaries are available for: | |
- macOS (Intel and Apple Silicon) | |
- Linux (Intel and ARM) | |
files: | | |
dist/jfvm-darwin-amd64 | |
dist/jfvm-darwin-arm64 | |
dist/jfvm-linux-amd64 | |
dist/jfvm-linux-arm64 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: false | |
prerelease: false | |
- name: Generate Homebrew formula | |
run: | | |
# Remove 'v' prefix from tag for version | |
VERSION="${{ steps.tag.outputs.tag }}" | |
VERSION_NO_V="${VERSION#v}" | |
cat <<EOF > jfvm.rb | |
class Jfvm < Formula | |
desc "JFrog CLI Version Manager" | |
homepage "https://github.com/${{ github.repository }}" | |
version "${VERSION_NO_V}" | |
if OS.mac? | |
if Hardware::CPU.arm? | |
url "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/jfvm-darwin-arm64" | |
sha256 "$(shasum -a 256 dist/jfvm-darwin-arm64 | awk '{print \$1}')" | |
else | |
url "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/jfvm-darwin-amd64" | |
sha256 "$(shasum -a 256 dist/jfvm-darwin-amd64 | awk '{print \$1}')" | |
end | |
elsif OS.linux? | |
if Hardware::CPU.arm? | |
url "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/jfvm-linux-arm64" | |
sha256 "$(shasum -a 256 dist/jfvm-linux-arm64 | awk '{print \$1}')" | |
else | |
url "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/jfvm-linux-amd64" | |
sha256 "$(shasum -a 256 dist/jfvm-linux-amd64 | awk '{print \$1}')" | |
end | |
end | |
def install | |
bin.install "jfvm-#{OS.mac? ? 'darwin' : 'linux'}-#{Hardware::CPU.arm? ? 'arm64' : 'amd64'}" => "jfvm" | |
end | |
test do | |
system "#{bin}/jfvm", "--version" | |
end | |
end | |
EOF | |
- name: Upload formula to artifacts | |
uses: actions/upload-artifact@v4.6.2 | |
with: | |
name: jfvm.rb | |
path: jfvm.rb |