Adds stale issue management and refines CI workflows #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ "master", "develop" ] | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| branches: [ "master", "develop" ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go: [1.21.x, 1.22.x, 1.23.x, 1.24.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go ${{ matrix.go }} | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go }} | |
| check-latest: true | |
| cache-dependency-path: "**/*.sum" | |
| - name: Download dependencies | |
| run: go mod download && echo "Download successful" || go mod tidy && echo "Tidy successful" || return 1 | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Build | |
| run: go build -v ./... | |
| - name: Run tests | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Run go vet | |
| run: go vet ./... | |
| - name: Run go fmt | |
| run: | | |
| if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
| echo "The following files are not formatted:" | |
| gofmt -s -l . | |
| exit 1 | |
| fi | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| flags: Go ${{ matrix.go }} | |
| slug: kjanat/articulate-parser | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| flags: Go ${{ matrix.go }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| dependency-review: | |
| name: Dependency Review | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| if: github.event_name == 'pull_request' | |
| needs: [ "test" ] | |
| steps: | |
| - name: 'Checkout Repository' | |
| uses: actions/checkout@v4 | |
| - name: 'Dependency Review' | |
| uses: actions/dependency-review-action@v4 | |
| with: | |
| fail-on-severity: moderate | |
| comment-summary-in-pr: always | |
| # # Use comma-separated names to pass list arguments: | |
| # deny-licenses: LGPL-2.0, BSD-2-Clause | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: github.ref_type == 'tag' | |
| permissions: | |
| contents: write | |
| needs: [ "test", "dependency-review" ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| check-latest: true | |
| - name: Run tests | |
| run: go test -v ./... | |
| - name: Build binaries | |
| run: | | |
| # Build for different platforms | |
| OS = ["darwin", "freebsd", "linux", "windows"] | |
| ARCH = ["amd64", "arm64"] | |
| for os in OS: | |
| for arch in ARCH: | |
| GOOS=$os GOARCH=$arch go build -o articulate-parser-$os-$arch main.go | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: articulate-parser-* | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |