Skip to content

Commit

Permalink
Use Github Actions for release and goreleaser-cross (#28)
Browse files Browse the repository at this point in the history
* Use Github Actions for release and goreleaser-cross
  • Loading branch information
treydock authored Jan 8, 2025
1 parent d695621 commit 4d535f0
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 75 deletions.
49 changes: 0 additions & 49 deletions .circleci/config.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

Check warning on line 1 in .github/workflows/release.yaml

View workflow job for this annotation

GitHub Actions / Test

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/release.yaml

View workflow job for this annotation

GitHub Actions / Test

3:1 [truthy] truthy value should be one of [false, true]
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-latest
name: Create Release
steps:
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: creekorful/goreportcard-action@v1.0
- name: setup release environment
run: |-
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
- name: Run GoReleaser
run: make release
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

Check warning on line 1 in .github/workflows/test.yaml

View workflow job for this annotation

GitHub Actions / Test

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/test.yaml

View workflow job for this annotation

GitHub Actions / Test

3:1 [truthy] truthy value should be one of [false, true]
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: make
- name: Run coverage
run: make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run GoReleaser build
run: make release-test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/.tarballs
/.build
/ondemand_exporter
/coverage.txt
/dist
/.release-env
58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
env:
- CGO_ENABLED=1
builds:
- id: amd64
main: ondemand_exporter.go
env:
- CC=x86_64-linux-gnu-gcc
goos:
- linux
goarch:
- amd64
ldflags:
- -extldflags "-static"
- -X github.com/prometheus/common/version.Version={{.Version}}
- -X github.com/prometheus/common/version.Revision={{.FullCommit}}
- -X github.com/prometheus/common/version.Branch={{.Branch}}
- -X github.com/prometheus/common/version.BuildUser=goreleaser
- -X github.com/prometheus/common/version.BuildDate={{.Date}}
- id: arm64
main: ondemand_exporter.go
env:
- CC=aarch64-linux-gnu-gcc
goos:
- linux
goarch:
- arm64
ldflags:
- -extldflags "-static"
- -X github.com/prometheus/common/version.Version={{.Version}}
- -X github.com/prometheus/common/version.Revision={{.FullCommit}}
- -X github.com/prometheus/common/version.Branch={{.Branch}}
- -X github.com/prometheus/common/version.BuildUser=goreleaser
- -X github.com/prometheus/common/version.BuildDate={{.Date}}
archives:
- id: archive
builds:
- amd64
- arm64
files:
- LICENSE
- CHANGELOG.md
name_template: "ondemand_exporter-{{ .Version }}.{{ .Os }}-{{ .Arch }}"
wrap_in_directory: true
checksum:
name_template: 'checksums.txt'
release:
prerelease: auto
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
51 changes: 26 additions & 25 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# yamllint disable rule:line-length
go:

Check warning on line 2 in .promu.yml

View workflow job for this annotation

GitHub Actions / Test

2:1 [document-start] missing document start "---"
version: 1.23
cgo: true
repository:
path: github.com/OSC/ondemand_exporter
path: github.com/OSC/ondemand_exporter
build:
binaries:
- name: ondemand_exporter
path: .
flags: -a -tags netgo
ldflags: |
-extldflags "-static"
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.Revision}}
-X github.com/prometheus/common/version.Branch={{.Branch}}
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
binaries:
- name: ondemand_exporter
path: .
flags: -a -tags netgo
ldflags: |
-extldflags "-static"
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.Revision}}
-X github.com/prometheus/common/version.Branch={{.Branch}}
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
files:
- LICENSE
- CHANGELOG.md
- files
files:
- LICENSE
- CHANGELOG.md
- files
crossbuild:
platforms:
- linux/amd64
- linux/386
- linux/arm64
- linux/mips
- linux/mipsle
- linux/mips64
- linux/mips64le
- linux/ppc64le
platforms:
- linux/amd64
- linux/386
- linux/arm64
- linux/mips
- linux/mipsle
- linux/mips64
- linux/mips64le
- linux/ppc64le
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Needs to be defined before including Makefile.common to auto-generate targets
DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le s390x
DOCKER_ARCHS ?= amd64 arm64
DOCKER_REPO ?= ohiosupercomputer
export GOPATH ?= $(firstword $(subst :, ,$(shell go env GOPATH)))
GOLANG_CROSS_VERSION ?= v1.23.3

include Makefile.common

Expand All @@ -10,6 +11,18 @@ DOCKER_IMAGE_NAME ?= ondemand_exporter
coverage:
go test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic ./...

release-test:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/work -w /work \
ghcr.io/goreleaser/goreleaser-cross:$(GOLANG_CROSS_VERSION) \
build --snapshot --clean

release:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
--env-file .release-env -v `pwd`:/work -w /work \
ghcr.io/goreleaser/goreleaser-cross:$(GOLANG_CROSS_VERSION) \
release --clean

%/.unpacked: %.ttar
@echo ">> extracting fixtures"
./ttar -C $(dir $*) -x -f $*.ttar
Expand Down

0 comments on commit 4d535f0

Please sign in to comment.