From b7baef0b9fb364518d2c261b978077a73008b242 Mon Sep 17 00:00:00 2001 From: Adam Snyder Date: Sun, 30 Jun 2024 20:02:47 -0700 Subject: [PATCH] chore: Add release automation and upgrade CI actions --- .github/.release-please-manifest.json | 1 + .github/release-please-config.json | 10 +++++ .github/workflows/ci.yaml | 57 +++++++++++++++++---------- 3 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 .github/.release-please-manifest.json create mode 100644 .github/release-please-config.json diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000..1c861e1 --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1 @@ +{".":"0.3.0"} diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..078c292 --- /dev/null +++ b/.github/release-please-config.json @@ -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 + } + } +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1f77dd0..741df0f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 @@ -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 @@ -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