Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on:
push:
tags:
- '**'
branches:
- '**'

jobs:

test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.25

- name: Vet
run: go vet ./...

- name: Test
run: go test ./...

release:

needs: test

if: startsWith(github.ref, 'refs/tags/')

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.25

- name: Build
run: |
versionflags="-X main.appVersion=${{ github.ref_name }}"
for GOOS in linux; do
for GOARCH in amd64 arm64; do
export GOOS GOARCH
CGO_ENABLED=0 go build -v -a -tags netgo -ldflags="-extldflags '-static' -s -w $versionflags" -o build/github-exporter-${GOOS}-${GOARCH} cmd/main.go
done
done
cd build; sha256sum * > sha256sums.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
build/*

docker:

needs: test

if: startsWith(github.ref, 'refs/tags/')

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository_owner }}/github-exporter
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github Packages
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Loading