diff --git a/.github/renovate.json5 b/.github/renovate.json5 index d70556b..de262c6 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -25,6 +25,30 @@ ], }, packageRules: [ + { + // Normal Go module updates wait 3 days after release, so a compromised + // version is more likely to be caught upstream before Renovate proposes + // it. Security fixes are not delayed (vulnerabilityAlerts sets no + // minimumReleaseAge). Scoped to Go modules: the Go proxy publishes + // release dates, and updates without one would be held back forever. + matchDatasources: [ + 'go', + ], + minimumReleaseAge: '3 days', + }, + { + // Pin Dockerfile images by digest (base image, dockerfile syntax), so a + // build always uses the exact image Renovate proposed; digest updates come + // as PRs. Not golang: CI sets its tag from go.mod's toolchain, the ARG + // default only matters for local builds. Not example/ package refs. + matchManagers: [ + 'dockerfile', + ], + matchPackageNames: [ + '!golang', + ], + pinDigests: true, + }, { matchManagers: [ 'crossplane', diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb4f1e3..deab003 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,15 +12,20 @@ on: description: Package version (e.g. v0.1.0) required: false +# Least privilege for GITHUB_TOKEN: nothing here writes to the repository +# (packages are pushed with the Upbound robot credentials). +permissions: + contents: read + env: # Common versions. Go comes from each repo's go.mod (toolchain directive). GOLANGCI_VERSION: 'v2.11.4' DOCKER_BUILDX_VERSION: 'v0.23.0' - # These environment variables are important to the Crossplane CLI install.sh - # script. They determine what version it installs. - XP_CHANNEL: master # TODO(negz): Pin to stable once v1.14 is released. - XP_VERSION: current # TODO(negz): Pin to a version once v1.14 is released. + # Crossplane CLI used to build and push the package: a pinned stable release + # (Renovate in upbound/sa-up bumps XP_VERSION). + XP_CHANNEL: stable + XP_VERSION: v2.5.0 # This CI job will automatically push new builds to xpkg.upbound.io if the # XPKG_ACCESS_ID and XPKG_TOKEN secrets are set in the GitHub respository (or @@ -125,8 +130,16 @@ jobs: GO_VERSION=${{ env.GO_VERSION }} outputs: type=docker,dest=runtime-${{ matrix.arch }}.tar + # Pinned release, verified against the checksum published next to it + # (XP_VERSION is bumped by Renovate in upbound/sa-up). The runner is + # linux/amd64; matrix.arch is only the package's target platform. - name: Setup the Crossplane CLI - run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh" + run: | + base="https://cli.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/linux_amd64" + curl -sSfL "${base}/crossplane" -o crossplane + echo "$(curl -sSfL "${base}/crossplane.sha256" | cut -d' ' -f1) crossplane" | sha256sum -c - + chmod +x crossplane + ./crossplane version --client - name: Build Package run: ./crossplane xpkg build --package-file=${{ matrix.arch }}.xpkg --package-root=package/ --embed-runtime-image-tarball=runtime-${{ matrix.arch }}.tar @@ -157,8 +170,16 @@ jobs: merge-multiple: true pattern: "!*.dockerbuild" # This gets uploaded by docker/build-push-action but must be skipped: https://github.com/actions/toolkit/pull/1874 + # Pinned release, verified against the checksum published next to it + # (XP_VERSION is bumped by Renovate in upbound/sa-up). The runner is + # linux/amd64; matrix.arch is only the package's target platform. - name: Setup the Crossplane CLI - run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh" + run: | + base="https://cli.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/linux_amd64" + curl -sSfL "${base}/crossplane" -o crossplane + echo "$(curl -sSfL "${base}/crossplane.sha256" | cut -d' ' -f1) crossplane" | sha256sum -c - + chmod +x crossplane + ./crossplane version --client - name: Login to Upbound uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 21c5963..966e399 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -44,6 +44,10 @@ concurrency: cancel-in-progress: true env: + # Pinned CLI versions (Renovate in upbound/sa-up bumps them). + UP_VERSION: v0.56.0 + XP_CHANNEL: stable + XP_VERSION: v2.5.0 UP_API_TOKEN: ${{ secrets.UP_E2E_API_TOKEN }} UP_ORG: ${{ secrets.UP_E2E_ORG }} UP_GROUP: ${{ secrets.UP_E2E_GROUP }} @@ -119,6 +123,7 @@ jobs: if: steps.harness.outputs.present == 'true' uses: upbound/action-up@53fe6395637d884c80d2bbc8c2d75d0ece776ced # v1 with: + version: ${{ env.UP_VERSION }} api-token: ${{ env.UP_API_TOKEN }} organization: ${{ env.UP_ORG }} @@ -147,9 +152,17 @@ jobs: GO_VERSION=${{ env.GO_VERSION }} outputs: type=docker,dest=runtime-amd64.tar + # Pinned release, verified against the checksum published next to it + # (XP_VERSION is bumped by Renovate in upbound/sa-up). The runner is + # linux/amd64; matrix.arch is only the package's target platform. - name: Setup the Crossplane CLI if: steps.harness.outputs.present == 'true' - run: curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh + run: | + base="https://cli.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/linux_amd64" + curl -sSfL "${base}/crossplane" -o crossplane + echo "$(curl -sSfL "${base}/crossplane.sha256" | cut -d' ' -f1) crossplane" | sha256sum -c - + chmod +x crossplane + ./crossplane version --client - name: Build and push the function dev package if: steps.harness.outputs.present == 'true' diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 3c01a2a..a4dffb3 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -10,6 +10,10 @@ on: description: 'Tag message' required: true +# Least privilege for GITHUB_TOKEN: creating the tag is the only write. +permissions: + contents: write + jobs: create-tag: runs-on: ubuntu-latest