Skip to content

Merge pull request #47 from shiguredo/feature/new-metrics #25

Merge pull request #47 from shiguredo/feature/new-metrics

Merge pull request #47 from shiguredo/feature/new-metrics #25

Workflow file for this run

name: Release Build
on:
push:
tags:
- "*"
jobs:
build:
name: build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- run: go install github.com/tcnksm/ghr@latest
- name: Build
run: |
VERSION=$(git describe --tag --abbrev=0)
REVISION=$(git rev-parse --short HEAD)
GOOS=linux GOARCH=amd64 go build \
-o dist/sora_exporter_linux_amd64-${VERSION} \
-ldflags "\
-X github.com/prometheus/common/version.Version=${VERSION} \
-X github.com/prometheus/common/version.Revision=${REVISION} \
-X github.com/prometheus/common/version.Branch=main \
-X github.com/prometheus/common/version.BuildUser=shiguredo \
-X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \
" \
main.go
GOOS=linux GOARCH=arm64 go build \
-o dist/sora_exporter_linux_arm64-${VERSION} \
-ldflags "\
-X github.com/prometheus/common/version.Version=${VERSION} \
-X github.com/prometheus/common/version.Revision=${REVISION} \
-X github.com/prometheus/common/version.Branch=main \
-X github.com/prometheus/common/version.BuildUser=shiguredo \
-X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \
" \
main.go
gzip dist/*
- name: Release
run: |
VERSION=$(git describe --tag --abbrev=0)
if [[ "${VERSION}" == *"canary"* ]]; then
ghr -t "${{ secrets.GITHUB_TOKEN }}" \
-u "${{ github.repository_owner }}" \
-r "sora_exporter" \
-n "${VERSION}" \
-replace \
-prerelease \
"${GITHUB_REF##*/}" \
dist/
else
ghr -t "${{ secrets.GITHUB_TOKEN }}" \
-u "${{ github.repository_owner }}" \
-r "sora_exporter" \
-n "${VERSION}" \
-replace \
"${GITHUB_REF##*/}" \
dist/
fi