|
| 1 | +name: Release 1.5.0 |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - chore/secure-build |
| 7 | + |
| 8 | +env: |
| 9 | + DOCKER_PLATFORMS: "linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386,linux/riscv64" |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.ref_name }}-release |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + variables: |
| 20 | + name: Setup variables |
| 21 | + runs-on: ubuntu-24.04 |
| 22 | + outputs: |
| 23 | + tag: ${{ steps.vars.outputs.tag }} |
| 24 | + short_tag: ${{ steps.vars.outputs.short_tag }} |
| 25 | + steps: |
| 26 | + - name: Checkout Repository |
| 27 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 28 | + |
| 29 | + - name: Set up Go |
| 30 | + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 |
| 31 | + with: |
| 32 | + go-version: stable |
| 33 | + |
| 34 | + - name: Get version |
| 35 | + id: vars |
| 36 | + run: | |
| 37 | + echo "tag=1.5.0" >> $GITHUB_OUTPUTS |
| 38 | + echo "short_tag=1.5" >> $GITHUB_OUTPUTS |
| 39 | +
|
| 40 | + build-docker: |
| 41 | + name: Build Docker Image |
| 42 | + runs-on: ubuntu-24.04 |
| 43 | + needs: variables |
| 44 | + permissions: |
| 45 | + contents: write # for lucacome/draft-release to create/update release draft |
| 46 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 47 | + id-token: write # for OIDC login to AWS ECR and goreleaser/goreleaser-action to sign artifacts |
| 48 | + packages: write # for docker/build-push-action to push to GHCR |
| 49 | + issues: write # for goreleaser/goreleaser-action to close milestones |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Checkout Repository |
| 53 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 54 | + with: |
| 55 | + ref: v${{ needs.variables.outputs.tag }} |
| 56 | + |
| 57 | + - name: Setup Golang Environment |
| 58 | + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 |
| 59 | + with: |
| 60 | + go-version: stable |
| 61 | + |
| 62 | + - name: Setup QEMU |
| 63 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 64 | + |
| 65 | + - name: Docker Buildx |
| 66 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 67 | + with: |
| 68 | + version: latest |
| 69 | + driver-opts: network=host |
| 70 | + |
| 71 | + - name: DockerHub Login |
| 72 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 73 | + with: |
| 74 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 75 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 76 | + |
| 77 | + - name: Login to GitHub Container Registry |
| 78 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 79 | + with: |
| 80 | + registry: ghcr.io |
| 81 | + username: ${{ github.repository_owner }} |
| 82 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + |
| 84 | + - name: Configure AWS Credentials |
| 85 | + uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0 |
| 86 | + with: |
| 87 | + aws-region: us-east-1 |
| 88 | + role-to-assume: ${{ secrets.AWS_ROLE_PUBLIC_ECR }} |
| 89 | + |
| 90 | + - name: Login to Public ECR |
| 91 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 92 | + with: |
| 93 | + registry: public.ecr.aws |
| 94 | + |
| 95 | + - name: Login to Quay.io |
| 96 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 97 | + with: |
| 98 | + registry: quay.io |
| 99 | + username: ${{ secrets.QUAY_USERNAME }} |
| 100 | + password: ${{ secrets.QUAY_ROBOT_TOKEN }} |
| 101 | + |
| 102 | + - name: Docker meta |
| 103 | + id: meta |
| 104 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 105 | + with: |
| 106 | + images: | |
| 107 | + name=nginx/nginx-prometheus-exporter,enable=true |
| 108 | + name=ghcr.io/nginx/nginx-prometheus-exporter,enable=true |
| 109 | + name=public.ecr.aws/nginx/nginx-prometheus-exporter,enable=true |
| 110 | + name=quay.io/nginx/nginx-prometheus-exporter,enable=true |
| 111 | + tags: | |
| 112 | + type=raw,value=${{ needs.variables.outputs.tag }} |
| 113 | + type=raw,value=${{ needs.variables.outputs.short_tag }} |
| 114 | + type=raw,value=latest |
| 115 | + labels: | |
| 116 | + org.opencontainers.image.vendor=NGINX Inc <[email protected]> |
| 117 | + env: |
| 118 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index |
| 119 | + |
| 120 | + - name: Download Syft |
| 121 | + uses: anchore/sbom-action/download-syft@f8bdd1d8ac5e901a77a92f111440fdb1b593736b # v0.20.6 |
| 122 | + |
| 123 | + - name: Install Cosign |
| 124 | + uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0 |
| 125 | + |
| 126 | + - name: Run GoReleaser |
| 127 | + uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 |
| 128 | + with: |
| 129 | + version: v2.12.5 # renovate: datasource=github-tags depName=goreleaser/goreleaser |
| 130 | + args: build --snapshot --clean |
| 131 | + env: |
| 132 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + NGINX_GITHUB_TOKEN: ${{ secrets.NGINX_PAT }} |
| 134 | + GORELEASER_CURRENT_TAG: "v${{ needs.variables.outputs.tag }}" |
| 135 | + |
| 136 | + - name: Print NGINX Prometheus Exporter info |
| 137 | + run: | |
| 138 | + ./dist/nginx-prometheus-exporter_linux_amd64_v1/nginx-prometheus-exporter --version |
| 139 | + find dist -type f |
| 140 | + continue-on-error: false |
| 141 | + |
| 142 | + # - name: Build and Push Docker Image |
| 143 | + # uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 144 | + # with: |
| 145 | + # file: build/Dockerfile |
| 146 | + # context: "." |
| 147 | + # target: goreleaser |
| 148 | + # platforms: ${{ env.DOCKER_PLATFORMS }} |
| 149 | + # tags: ${{ steps.meta.outputs.tags }} |
| 150 | + # labels: ${{ steps.meta.outputs.labels }} |
| 151 | + # annotations: ${{ steps.meta.outputs.annotations }} |
| 152 | + # push: true |
| 153 | + # cache-from: type=gha,scope=exporter |
| 154 | + # cache-to: type=gha,scope=exporter,mode=max |
| 155 | + # no-cache: true |
| 156 | + # provenance: mode=max |
| 157 | + # sbom: true |
0 commit comments