Skip to content

chore(master): release 1.22.2 (#58) #34

chore(master): release 1.22.2 (#58)

chore(master): release 1.22.2 (#58) #34

Workflow file for this run

---
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- runner: macos-latest
goos: darwin
goarch: amd64
cc: clang -arch x86_64
- runner: macos-latest
goos: darwin
goarch: arm64
- runner: ubuntu-latest
goos: linux
goarch: amd64
- runner: ubuntu-24.04-arm
goos: linux
goarch: arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
with:
go-version-file: go.mod
cache: true
- name: Build
env:
CGO_ENABLED: "1"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CC: ${{ matrix.cc || '' }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o tero ./cmd/tero
- name: Package
run: |
VERSION="${GITHUB_REF_NAME#v}"
ARCHIVE="tero_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
tar czf "${ARCHIVE}" tero LICENSE
shasum -a 256 "${ARCHIVE}" > "${ARCHIVE}.sha256"
echo "ARCHIVE=${ARCHIVE}" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: tero-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
tero_*.tar.gz
tero_*.tar.gz.sha256
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
path: artifacts
merge-multiple: true
- name: Create checksums
working-directory: artifacts
run: |
cat *.sha256 > checksums.txt
rm *.sha256
- name: Upload release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Release-please creates the release; we just upload assets.
# If the release doesn't exist yet (e.g. rc tags), create it.
if ! gh release view "${GITHUB_REF_NAME}" &>/dev/null; then
PRERELEASE=""
if [[ "${GITHUB_REF_NAME}" == *-* ]]; then
PRERELEASE="--prerelease"
fi
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--generate-notes \
${PRERELEASE}
fi
gh release upload "${GITHUB_REF_NAME}" \
artifacts/*.tar.gz \
artifacts/checksums.txt \
scripts/install.sh \
--clobber
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2
with:
app-id: ${{ secrets.TERO_BOT_CLIENT_ID }}
private-key: ${{ secrets.TERO_BOT_PRIVATE_SIGNING_KEY }}
owner: ${{ github.repository_owner }}
repositories: homebrew-tap
- name: Update Homebrew formula
if: ${{ !contains(github.ref_name, '-') }}
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
BASE_URL="https://github.com/usetero/cli/releases/download/${GITHUB_REF_NAME}"
darwin_amd64_sha=$(awk '/darwin_amd64/ {print $1}' artifacts/checksums.txt)
darwin_arm64_sha=$(awk '/darwin_arm64/ {print $1}' artifacts/checksums.txt)
linux_amd64_sha=$(awk '/linux_amd64/ {print $1}' artifacts/checksums.txt)
linux_arm64_sha=$(awk '/linux_arm64/ {print $1}' artifacts/checksums.txt)
cat > /tmp/tero.rb <<EOF
# typed: false
# frozen_string_literal: true
class Tero < Formula
desc "Improve your observability data quality from the terminal"
homepage "https://usetero.com"
version "${VERSION}"
license "Apache-2.0"
on_macos do
if Hardware::CPU.intel?
url "${BASE_URL}/tero_${VERSION}_darwin_amd64.tar.gz"
sha256 "${darwin_amd64_sha}"
def install
bin.install "tero"
end
end
if Hardware::CPU.arm?
url "${BASE_URL}/tero_${VERSION}_darwin_arm64.tar.gz"
sha256 "${darwin_arm64_sha}"
def install
bin.install "tero"
end
end
end
on_linux do
if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
url "${BASE_URL}/tero_${VERSION}_linux_amd64.tar.gz"
sha256 "${linux_amd64_sha}"
def install
bin.install "tero"
end
end
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
url "${BASE_URL}/tero_${VERSION}_linux_arm64.tar.gz"
sha256 "${linux_arm64_sha}"
def install
bin.install "tero"
end
end
end
test do
system "#{bin}/tero", "--version"
end
end
EOF
# Remove leading whitespace from heredoc
sed -i 's/^ //' /tmp/tero.rb
cd "$(mktemp -d)"
git clone "https://x-access-token:${GH_TOKEN}@github.com/usetero/homebrew-tap.git" .
cp /tmp/tero.rb Formula/tero.rb
git config user.name "tero-bot[bot]"
git config user.email "tero-bot[bot]@users.noreply.github.com"
git add Formula/tero.rb
git commit -m "tero ${VERSION}"
git push