fix: infer raft leader from MYSELF when LEADER line absent in single-… #6
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| APP_NAME: eos-tui | |
| HOMEBREW_TAP_REPO: lobis/homebrew-tap | |
| jobs: | |
| verify: | |
| name: Verify release tag and Go checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Validate tag format | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ ! "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Release tags must match vMAJOR.MINOR.PATCH, got ${GITHUB_REF_NAME}" | |
| exit 1 | |
| fi | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Verify formatting | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| unformatted="$(gofmt -l .)" | |
| if [ -n "$unformatted" ]; then | |
| echo "These files need gofmt:" | |
| echo "$unformatted" | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| env: | |
| EOS_TEST_SKIP: "1" | |
| run: go test ./... | |
| - name: Build repository | |
| run: go build ./... | |
| build-native: | |
| name: Build ${{ matrix.label }} | |
| needs: verify | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - label: Linux amd64 | |
| runner: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| exe_suffix: "" | |
| asset_suffix: linux_amd64 | |
| - label: Linux arm64 | |
| runner: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| exe_suffix: "" | |
| asset_suffix: linux_arm64 | |
| - label: macOS arm64 | |
| runner: macos-latest | |
| goos: darwin | |
| goarch: arm64 | |
| exe_suffix: "" | |
| asset_suffix: macos_arm64 | |
| - label: Windows amd64 | |
| runner: windows-latest | |
| goos: windows | |
| goarch: amd64 | |
| exe_suffix: .exe | |
| asset_suffix: windows_amd64 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Build binary | |
| shell: bash | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| EXE_SUFFIX: ${{ matrix.exe_suffix }} | |
| ASSET_SUFFIX: ${{ matrix.asset_suffix }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| CGO_ENABLED=0 go build \ | |
| -trimpath \ | |
| -buildvcs=false \ | |
| -ldflags="-s -w -X main.version=${GITHUB_REF_NAME}" \ | |
| -o "dist/${APP_NAME}_${GITHUB_REF_NAME}_${ASSET_SUFFIX}${EXE_SUFFIX}" \ | |
| . | |
| - name: Upload binary | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-${{ matrix.asset_suffix }} | |
| path: dist/${{ env.APP_NAME }}_${{ github.ref_name }}_${{ matrix.asset_suffix }}${{ matrix.exe_suffix }} | |
| build-rpm: | |
| name: Build RPM AlmaLinux ${{ matrix.alma_major }} ${{ matrix.arch }} | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - alma_major: "9" | |
| arch: x86_64 | |
| platform: linux/amd64 | |
| go_bootstrap_arch: amd64 | |
| - alma_major: "9" | |
| arch: aarch64 | |
| platform: linux/arm64 | |
| go_bootstrap_arch: arm64 | |
| - alma_major: "10" | |
| arch: x86_64 | |
| platform: linux/amd64 | |
| go_bootstrap_arch: amd64 | |
| - alma_major: "10" | |
| arch: aarch64 | |
| platform: linux/arm64 | |
| go_bootstrap_arch: arm64 | |
| steps: | |
| - name: Set up QEMU | |
| if: matrix.arch == 'aarch64' | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Prepare RPM sources | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| version="${GITHUB_REF_NAME#v}" | |
| rm -rf packaging | |
| mkdir -p packaging/SOURCES packaging/SPECS | |
| git archive --format=tar.gz --prefix="${APP_NAME}-${version}/" -o "packaging/SOURCES/${APP_NAME}-${version}.tar.gz" HEAD | |
| cp "${APP_NAME}.spec" packaging/SPECS/ | |
| - name: Build RPM | |
| shell: bash | |
| env: | |
| ALMA_IMAGE: almalinux:${{ matrix.alma_major }} | |
| CONTAINER_PLATFORM: ${{ matrix.platform }} | |
| GO_BOOTSTRAP_ARCH: ${{ matrix.go_bootstrap_arch }} | |
| run: | | |
| set -euo pipefail | |
| version="${GITHUB_REF_NAME#v}" | |
| go_version="$(awk '/^go / { print $2 }' go.mod)" | |
| docker run --rm \ | |
| --platform "${CONTAINER_PLATFORM}" \ | |
| -v "${PWD}:/workspace" \ | |
| -w /workspace \ | |
| "${ALMA_IMAGE}" \ | |
| bash -lc ' | |
| set -euo pipefail | |
| dnf install -y tar gzip rpm-build | |
| curl -fsSL "https://go.dev/dl/go'"${go_version}"'.linux-'"${GO_BOOTSTRAP_ARCH}"'.tar.gz" -o /tmp/go.tgz | |
| rm -rf /usr/local/go | |
| tar -C /usr/local -xzf /tmp/go.tgz | |
| export PATH=/usr/local/go/bin:$PATH | |
| rpmbuild \ | |
| --define "_topdir /workspace/packaging" \ | |
| --define "pkg_version '"${version}"'" \ | |
| --define "pkg_release 1" \ | |
| -bb /workspace/packaging/SPECS/'"${APP_NAME}"'.spec | |
| ' | |
| - name: Upload RPM | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-rpm-el${{ matrix.alma_major }}-${{ matrix.arch }} | |
| path: packaging/RPMS/*/*.rpm | |
| github-release: | |
| name: Create GitHub release | |
| needs: [build-native, build-rpm] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: release-artifacts | |
| merge-multiple: true | |
| - name: Flatten artifacts | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # RPM artifacts are downloaded into arch subdirectories; bring everything | |
| # up to the top level so checksums and the release upload see flat files. | |
| find release-artifacts -mindepth 2 -type f -exec mv {} release-artifacts/ \; | |
| find release-artifacts -type d -empty -delete | |
| - name: Generate checksums | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd release-artifacts | |
| find . -type f | sort | xargs sha256sum | sed 's|\./||' > SHA256SUMS.txt | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release-artifacts/* | |
| generate_release_notes: true | |
| update-homebrew-tap: | |
| name: Update Homebrew tap | |
| needs: github-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update tap formula | |
| shell: bash | |
| env: | |
| HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${HOMEBREW_TAP_GITHUB_TOKEN}" ]; then | |
| echo "::warning::HOMEBREW_TAP_GITHUB_TOKEN is not configured; skipping Homebrew tap update." | |
| exit 0 | |
| fi | |
| version="${GITHUB_REF_NAME#v}" | |
| base_url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}" | |
| # Download each platform binary and compute its sha256. | |
| declare -A sha | |
| for platform in macos_arm64 linux_amd64 linux_arm64; do | |
| url="${base_url}/${APP_NAME}_${GITHUB_REF_NAME}_${platform}" | |
| curl -fsSL -o "/tmp/${platform}" "${url}" | |
| sha["${platform}"]="$(sha256sum "/tmp/${platform}" | awk '{print $1}')" | |
| done | |
| git clone "https://x-access-token:${HOMEBREW_TAP_GITHUB_TOKEN}@github.com/${HOMEBREW_TAP_REPO}.git" /tmp/homebrew-tap | |
| mkdir -p /tmp/homebrew-tap/Formula | |
| cat > /tmp/homebrew-tap/Formula/eos-tui.rb <<EOF | |
| class EosTui < Formula | |
| desc "Terminal UI for monitoring and managing EOS storage clusters" | |
| homepage "https://github.com/${GITHUB_REPOSITORY}" | |
| version "${version}" | |
| license "MIT" | |
| on_macos do | |
| on_arm do | |
| url "${base_url}/${APP_NAME}_${GITHUB_REF_NAME}_macos_arm64" | |
| sha256 "${sha[macos_arm64]}" | |
| end | |
| end | |
| on_linux do | |
| on_intel do | |
| url "${base_url}/${APP_NAME}_${GITHUB_REF_NAME}_linux_amd64" | |
| sha256 "${sha[linux_amd64]}" | |
| end | |
| on_arm do | |
| if Hardware::CPU.is_64_bit? | |
| url "${base_url}/${APP_NAME}_${GITHUB_REF_NAME}_linux_arm64" | |
| sha256 "${sha[linux_arm64]}" | |
| end | |
| end | |
| end | |
| def install | |
| binary = "${APP_NAME}_${GITHUB_REF_NAME}_\#{OS.mac? ? "macos_arm64" : (Hardware::CPU.arm? ? "linux_arm64" : "linux_amd64")}" | |
| bin.install binary => "${APP_NAME}" | |
| end | |
| test do | |
| assert_match version.to_s, shell_output("#{bin}/${APP_NAME} --version") | |
| end | |
| end | |
| EOF | |
| cd /tmp/homebrew-tap | |
| if git diff --quiet -- Formula/eos-tui.rb; then | |
| echo "Homebrew formula already up to date." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add Formula/eos-tui.rb | |
| git commit -m "Update eos-tui to ${GITHUB_REF_NAME}" | |
| git push origin HEAD:main |