Skip to content

Commit

Permalink
chore: Add release automation and upgrade CI actions
Browse files Browse the repository at this point in the history
  • Loading branch information
armsnyder committed Jul 1, 2024
1 parent 441797c commit b7baef0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".":"0.3.0"}
10 changes: 10 additions & 0 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
".": {
"release-type": "go",
"bump-minor-pre-major": true,
"include-v-in-tag": true
}
}
}
57 changes: 36 additions & 21 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
name: CI
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

on:
- push
- pull_request
push:
branches:
- main
pull_request: {}
workflow_dispatch: {}

jobs:
Test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.20", "1.21", "1.22"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3

- name: Run Test
run: make test
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- run: go test -cover ./...

Lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: golangci/golangci-lint-action@v6
with:
version: v1.59.1

- name: Run Lint
uses: golangci/golangci-lint-action@v3
release-please:
runs-on: ubuntu-latest
needs: [Test, Lint]
if: github.ref == 'refs/heads/main'
steps:
- uses: googleapis/release-please-action@v4
id: release-please
with:
token: ${{ secrets.PAT }}
config-file: .github/release-please-config.json
manifest-file: .github/.release-please-manifest.json

Docker:
runs-on: ubuntu-latest
Expand All @@ -33,27 +48,27 @@ jobs:
- Lint
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: armsnyder/a2s-exporter

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: armsnyder
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Docker build
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
push: false
Expand All @@ -64,7 +79,7 @@ jobs:

- name: Docker build and push
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand Down

0 comments on commit b7baef0

Please sign in to comment.