chore(deps): pin dependencies #7
Workflow file for this run
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: Build and Publish Artifacts | |
| on: | |
| release: | |
| types: | |
| - published | |
| pull_request: | |
| jobs: | |
| # Run tests and format check | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Run tests | |
| run: make test | |
| # Build binaries for multiple platforms | |
| binary-build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, darwin] | |
| goarch: [arm64, amd64] | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Build | |
| run: | | |
| VERSION=${GITHUB_REF_NAME:-dev} | |
| BUILD_DATE=$(date +%Y%m%d-%H:%M:%S) | |
| GIT_REVISION=${GITHUB_SHA} | |
| GIT_BRANCH=${GITHUB_REF_NAME} | |
| GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \ | |
| -ldflags "-X github.com/prometheus/common/version.BuildDate=${BUILD_DATE} \ | |
| -X github.com/prometheus/common/version.BuildUser=github-actions \ | |
| -X github.com/prometheus/common/version.Branch=${GIT_BRANCH} \ | |
| -X github.com/prometheus/common/version.Revision=${GIT_REVISION} \ | |
| -X github.com/prometheus/common/version.Version=${VERSION}" \ | |
| -o prometheus-mailgun-exporter-${{ matrix.goos }}-${{ matrix.goarch }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: prometheus-mailgun-exporter-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: ./prometheus-mailgun-exporter-${{ matrix.goos }}-${{ matrix.goarch }} | |
| # Upload binaries to GitHub Release | |
| binary-release: | |
| if: github.event_name == 'release' | |
| needs: binary-build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| - name: Prep binaries | |
| run: | | |
| mkdir tmp | |
| mv prometheus-mailgun-exporter-*/* tmp/ | |
| - name: Generate SHA256 Checksum | |
| run: | | |
| cd tmp | |
| shasum -a 256 prometheus-mailgun-exporter-* > sha256sums.txt | |
| - name: Upload artifacts to GitHub Release | |
| uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2 | |
| with: | |
| draft: false | |
| prerelease: false | |
| files: | | |
| ./tmp/sha256sums.txt | |
| ./tmp/prometheus-mailgun-exporter-* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Build and publish Docker image to ghcr.io | |
| docker-ghcr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha,prefix= | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push to ghcr.io | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 | |
| with: | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| file: Dockerfile | |
| context: . | |
| build-args: | | |
| BUILD_DATE=${{ github.event.release.created_at || github.event.head_commit.timestamp }} | |
| BUILD_USER=github-actions | |
| GIT_BRANCH=${{ github.ref_name }} | |
| GIT_REVISION=${{ github.sha }} | |
| VERSION=${{ steps.meta.outputs.version }} |