diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ce3b1c..75c83b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,32 +6,54 @@ on: pull_request: branches: [main] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: name: Lint runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.24" + go-version-file: go.mod + cache-dependency-path: go.sum - name: golangci-lint uses: golangci/golangci-lint-action@v7 with: version: v2.10.1 - test: - name: Test + build: + name: Build runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.24" + go-version-file: go.mod + cache-dependency-path: go.sum + - name: Build package + run: go build ./... + test: + name: Test + Coverage + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: go.sum - name: Run tests with coverage run: go test -race -coverprofile=coverage.out -covermode=atomic ./... - - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5761e0b..e7f68dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,15 +3,20 @@ name: Release on: push: tags: - - "v[0-9]+.[0-9]+.[0-9]+*" + - "v*.*.*" permissions: contents: write +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + jobs: release: name: Release runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 with: @@ -20,28 +25,32 @@ jobs: - name: Generate release notes id: notes run: | - # Get the previous tag - PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + prev_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true) - if [ -n "$PREV_TAG" ]; then - echo "Generating changelog from $PREV_TAG to $GITHUB_REF_NAME" - NOTES=$(git log --pretty=format:"- %s" "$PREV_TAG"..HEAD) + if [ -n "$prev_tag" ]; then + echo "Generating changelog from $prev_tag to $GITHUB_REF_NAME" + notes=$(git log --pretty=format:'- %s' "$prev_tag"..HEAD) else echo "No previous tag found, using all commits" - NOTES=$(git log --pretty=format:"- %s") + notes=$(git log --pretty=format:'- %s') fi { echo "notes<> "$GITHUB_OUTPUT" - - name: Create GitHub Release - run: | - gh release create "$GITHUB_REF_NAME" \ - --title "$GITHUB_REF_NAME" \ - --notes "${{ steps.notes.outputs.notes }}" \ - --generate-notes + - name: Create or update GitHub release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then + gh release edit "$GITHUB_REF_NAME" \ + --title "$GITHUB_REF_NAME" \ + --notes "${{ steps.notes.outputs.notes }}" + else + gh release create "$GITHUB_REF_NAME" \ + --title "$GITHUB_REF_NAME" \ + --notes "${{ steps.notes.outputs.notes }}" + fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 635776c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: go - -go: - - "1.17" - - "1.18" - - "1.19" - - "1.20" - - "1.21" - - "1.22" - - tip - -before_install: - - go get -t -v ./... - -script: - - go test -coverprofile=coverage.txt -covermode=atomic - -after_success: - - bash <(curl -s https://codecov.io/bash) - -services: - - docker