# Code generated internal/ci/base/write.cue; DO NOT EDIT.

name: Release
concurrency: release
"on":
  push:
    tags:
      - v*
      - '!*-0.dev'
    branches:
      - ci/test
      - master
      - release-branch.*
jobs:
  goreleaser:
    defaults:
      run:
        shell: bash --noprofile --norc -euo pipefail {0}
    permissions:
      contents: read
      id-token: write
    runs-on: namespace-profile-linux-amd64-large
    if: ${{github.repository == 'cue-lang/cue'}}
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0
          persist-credentials: false
      - name: Reset git directory modification times
        run: touch -t 202211302355 $(find * -type d)
      - name: Restore git file modification times
        uses: chetan/git-restore-mtime-action@cbf8161ddb4e9b162409104954fb540e8a38c1da
      - id: DispatchTrailer
        name: Try to extract Dispatch-Trailer
        run: |-
          x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')"
          if [[ "$x" == "" ]]
          then
             # Some steps rely on the presence or otherwise of the Dispatch-Trailer.
             # We know that we don't have a Dispatch-Trailer in this situation,
             # hence we use the JSON value null in order to represent that state.
             # This means that GitHub expressions can determine whether a Dispatch-Trailer
             # is present or not by checking whether the fromJSON() result of the
             # output from this step is the JSON value null or not.
             x=null
          fi
          echo "value<<EOD" >> $GITHUB_OUTPUT
          echo "$x" >> $GITHUB_OUTPUT
          echo "EOD" >> $GITHUB_OUTPUT
      - if: |-
          ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
          Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, '
          Dispatch-Trailer: {"type":"'))
        name: Check we don't have Dispatch-Trailer on a protected branch
        run: |-
          echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch"
          false
      - name: Install Go
        uses: actions/setup-go@v6
        with:
          cache: false
          go-version: 1.26.4
      - name: Set common go env vars
        run: |-
          case $(go env GOARCH) in
          amd64) go env -w GOAMD64=v3 ;;   # 2013 and later; makes `go test -race` 15% faster
          arm64) go env -w GOARM64=v8.6 ;; # Apple M2 and later
          esac

          # Otherwise `go test -race` sleeps for 1s on every package;
          # see https://go.dev/issues/20364.
          echo "GORACE=atexit_sleep_ms=10" >> $GITHUB_ENV

          # Dump env for good measure
          go env
      - name: Setup qemu
        uses: docker/setup-qemu-action@v3
      - name: Docker Login
        uses: docker/login-action@v3
        with:
          registry: docker.io
          username: cueckoo
          password: ${{ secrets.CUECKOO_DOCKER_PAT }}
      - name: Login to CUE registry
        uses: cue-labs/registry-login-action@v1
      - name: Install GoReleaser
        uses: goreleaser/goreleaser-action@v6
        with:
          install-only: true
          version: v2.16.0
      - name: Run GoReleaser with CUE
        env:
          GITHUB_TOKEN: ${{ secrets.CUECKOO_GITHUB_PAT }}
        run: go tool cue cmd release
        working-directory: ./internal/ci/goreleaser
      - if: startsWith(github.ref, 'refs/tags/v')
        name: Re-test cuelang.org
        run: 'curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail --request POST --data-binary "{\"event_type\":\"Re-test post release of ${GITHUB_REF##refs/tags/}\"}" https://api.github.com/repos/cue-lang/cuelang.org/dispatches'
      - if: startsWith(github.ref, 'refs/tags/v')
        name: Trigger unity build
        run: 'curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PORCUEPINE_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail --request POST --data-binary "{\"event_type\":\"Check against CUE ${GITHUB_REF##refs/tags/}\",\"client_payload\":{\"type\":\"unity\",\"payload\":{\"versions\":\"\\\"${GITHUB_REF##refs/tags/}\\\"\"}}}" https://api.github.com/repos/cue-unity/unity-private/dispatches'
