diff --git a/.github/workflows/autoupdate.yaml b/.github/workflows/autoupdate.yaml new file mode 100644 index 0000000..77da16e --- /dev/null +++ b/.github/workflows/autoupdate.yaml @@ -0,0 +1,20 @@ +name: Autoupdate go.mod and go.sum + +on: + workflow_dispatch: + schedule: + - cron: "0 3 * * *" + +permissions: + contents: write + actions: write + pull-requests: write + security-events: write + +jobs: + autoupdate: + uses: lukaszraczylo/shared-actions/.github/workflows/go-autoupdate.yaml@main + with: + go-version: ">=1.24" + release-workflow: "release.yml" + secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..25d7b99 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,22 @@ +name: Pull Request + +on: + pull_request: + branches: + - main + push: + branches: + - "**" + - "!main" + +permissions: + contents: write + actions: write + pull-requests: write + security-events: write + +jobs: + pr-checks: + uses: lukaszraczylo/shared-actions/.github/workflows/go-pr.yaml@main + with: + go-version: ">=1.24" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 666eaf0..6ecc79d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,86 +2,26 @@ name: Release on: push: - branches: [main] + branches: + - main + paths: + - "**.go" + - "go.mod" + - "go.sum" + - "Dockerfile" + - ".goreleaser.yaml" workflow_dispatch: permissions: - contents: read - -concurrency: - group: release-${{ github.ref }} - cancel-in-progress: false + contents: write + packages: write + id-token: write jobs: release: - name: Version, tag, and release - runs-on: ubuntu-latest - timeout-minutes: 30 - permissions: - contents: write - packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Calculate semantic version - id: semver - uses: lukaszraczylo/semver-generator@b5eb8ae15a62d76e81dc4661a49209a8502cf1d3 # v1.17.18 - with: - config_file: semver.yaml - repository_local: true - existing: true - - - name: Create tag if new - id: tag - run: | - VERSION="v${{ steps.semver.outputs.semantic_version }}" - echo "version=${VERSION}" >> "$GITHUB_OUTPUT" - if git rev-parse "${VERSION}" >/dev/null 2>&1; then - echo "Tag ${VERSION} already exists; skipping release." - echo "new=false" >> "$GITHUB_OUTPUT" - else - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git tag -a "${VERSION}" -m "Release ${VERSION}" - git push origin "${VERSION}" - echo "new=true" >> "$GITHUB_OUTPUT" - fi - - - name: Set up Go - if: steps.tag.outputs.new == 'true' - uses: actions/setup-go@v7 - with: - go-version-file: go.mod - - - name: Run tests - if: steps.tag.outputs.new == 'true' - run: go test -race ./... - - - name: Set up QEMU - if: steps.tag.outputs.new == 'true' - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - - - name: Set up Docker Buildx - if: steps.tag.outputs.new == 'true' - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - - - name: Log in to GitHub Container Registry - if: steps.tag.outputs.new == 'true' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Run goreleaser - if: steps.tag.outputs.new == 'true' - uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 - with: - distribution: goreleaser - version: "~> v2" - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: lukaszraczylo/shared-actions/.github/workflows/go-release.yaml@main + with: + go-version: ">=1.24" + docker-enabled: true + docker-registry: ghcr.io + secrets: inherit