chore: bump actions/setup-go from 4 to 5 (#102) #47
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: Release | |
| on: | |
| # Trigger the workflow on push or pull request, | |
| # but only for the main branch | |
| push: | |
| branches: | |
| - master | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: grl-exporter | |
| OWNER: kalgurn | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: | |
| - '1.22' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} # The Go version to download (if necessary) and use. | |
| - name: Run Unit tests | |
| run: go test ./... -test.v | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to the Container registry | |
| uses: docker/[email protected] | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/[email protected] | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }} | |
| - name: Build and push Docker image | |
| uses: docker/[email protected] | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| outputs: | |
| changelog: ${{ steps.changelog.outputs.clean_changelog }} | |
| changelog_tag: ${{ steps.changelog.outputs.tag }} | |
| changelog_skipped: ${{ steps.changelog.outputs.skipped }} | |
| strategy: | |
| matrix: | |
| goos: | |
| - linux | |
| - darwin | |
| goarch: | |
| - amd64 | |
| - arm64 | |
| go-version: | |
| - '1.22' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Conventional Changelog Action | |
| id: changelog | |
| uses: TriPSs/conventional-changelog-action@v3 | |
| with: | |
| github-token: ${{ secrets.github_token }} | |
| git-message: 'chore(release): {version}' | |
| tag-prefix: 'v' | |
| version-file: './version.json' | |
| preset: 'conventionalcommits' | |
| output-file: 'false' | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} # The Go version to download (if necessary) and use. | |
| # Install all the dependencies | |
| - name: Install dependencies | |
| run: | | |
| go version | |
| go get -u golang.org/x/lint/golint | |
| # Run build of the application | |
| - name: Run build | |
| run: ./build.sh ${{ steps.changelog.outputs.tag }} | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 0 | |
| - name: Store intermediate artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grl-exporter-${{ matrix.goos }}-${{ matrix.goarch }}-${{ steps.changelog.outputs.tag }}.zip | |
| path: grl-exporter-${{ matrix.goos }}-${{ matrix.goarch }}.zip | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Download artifacts | |
| id: download | |
| uses: actions/download-artifact@v3 | |
| - name: Display structure of downloaded files | |
| id: files | |
| run: | | |
| echo "::set-output name=list::$(ls ./**/*.zip | jq --raw-input --slurp '.')" | |
| - name: Release with Notes | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| body: ${{ needs.build.outputs.changelog }} | |
| draft: true | |
| files: ${{ fromJSON(steps.files.outputs.list) }} |