Skip to content

Commit

Permalink
update CI/CD workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fbegyn committed Jul 29, 2023
1 parent f9db500 commit f6e0660
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 41 deletions.
45 changes: 5 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,24 @@
name: CI
name: test-collector

on:
push:
branches:
- main
tags:
- v.*
- 'main'

permissions:
contents: write
packages: write

jobs:
test:
test-collector:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19

- name: Test collector
run: go test -exec sudo -v ./collector/

goreleaser:
runs-on: ubuntu-latest
needs: [test]
if: contains(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: go test -v -exec sudo ./collector/
48 changes: 48 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: relase-tags

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
test-collector:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19

- name: Test collector
run: go test -v -exec sudo ./collector/

goreleaser:
runs-on: ubuntu-latest
needs: [test-collector]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19

- name: Fetch all tags
run: git fetch --force --tags

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ builds:
- linux
goarch:
- amd64
- arm64
main: ./cmd/tc_exporter
archives:
- id: arch
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/fbegyn/tc_exporter

go 1.20
go 1.19

require (
github.com/florianl/go-tc v0.4.2
Expand Down

0 comments on commit f6e0660

Please sign in to comment.