cuelang.org/go@v0.10.1/internal/ci/github/release.cue (about)

     1  // Copyright 2022 The CUE Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package github
    16  
    17  import (
    18  	"list"
    19  
    20  	"github.com/SchemaStore/schemastore/src/schemas/json"
    21  )
    22  
    23  // _cueVersionRef is a workflow job-runtime expression that evaluates to the
    24  // git tag (version) that is being released. Defining as a "constant" here for
    25  // re-use below
    26  _cueVersionRef: "${GITHUB_REF##refs/tags/}"
    27  
    28  // The release workflow
    29  workflows: release: _repo.bashWorkflow & {
    30  
    31  	name: "Release"
    32  
    33  	// We only want a single release happening at a time to avoid
    34  	// race conditions on updating the latest docker images or
    35  	// homebrew tags.
    36  	concurrency: "release"
    37  
    38  	on: push: {
    39  		tags: [_repo.releaseTagPattern, "!" + _repo.zeroReleaseTagPattern]
    40  		branches: list.Concat([[_repo.testDefaultBranch], _repo.protectedBranchPatterns])
    41  	}
    42  	jobs: goreleaser: {
    43  		"runs-on": _repo.linuxMachine
    44  		if:        "${{github.repository == '\(_repo.githubRepositoryPath)'}}"
    45  		steps: [
    46  			for v in _repo.checkoutCode {v},
    47  			_repo.installGo & {
    48  				with: "go-version": _repo.pinnedReleaseGo
    49  			},
    50  			json.#step & {
    51  				name: "Setup qemu"
    52  				uses: "docker/setup-qemu-action@v3"
    53  			},
    54  			json.#step & {
    55  				name: "Set up Docker Buildx"
    56  				uses: "docker/setup-buildx-action@v3"
    57  			},
    58  			json.#step & {
    59  				name: "Docker Login"
    60  				uses: "docker/login-action@v3"
    61  				with: {
    62  					registry: "docker.io"
    63  					username: "cueckoo"
    64  					password: "${{ secrets.CUECKOO_DOCKER_PAT }}"
    65  				}
    66  			},
    67  			json.#step & {
    68  				name: "Install CUE"
    69  				run:  "go install ./cmd/cue"
    70  			},
    71  			json.#step & {
    72  				name: "Install GoReleaser"
    73  				uses: "goreleaser/goreleaser-action@v5"
    74  				with: {
    75  					"install-only": true
    76  					version:        _repo.goreleaserVersion
    77  				}
    78  			},
    79  			json.#step & {
    80  				// Note that the logic for what gets run at release time
    81  				// is defined with the release command in CUE.
    82  				name: "Run GoReleaser with CUE"
    83  				env: GITHUB_TOKEN: "${{ secrets.CUECKOO_GITHUB_PAT }}"
    84  				run:                 "cue cmd release"
    85  				"working-directory": "./internal/ci/goreleaser"
    86  			},
    87  			_repo.repositoryDispatch & {
    88  				name:                  "Re-test cuelang.org"
    89  				if:                    _repo.isReleaseTag
    90  				#githubRepositoryPath: _repo.cuelangRepositoryPath
    91  				#arg: {
    92  					event_type: "Re-test post release of \(_cueVersionRef)"
    93  				}
    94  			},
    95  			_repo.repositoryDispatch & {
    96  				name:                          "Trigger unity build"
    97  				if:                            _repo.isReleaseTag
    98  				#githubRepositoryPath:         _repo.unityRepositoryPath
    99  				#botGitHubUserTokenSecretsKey: "PORCUEPINE_GITHUB_PAT"
   100  				#arg: {
   101  					event_type: "Check against CUE \(_cueVersionRef)"
   102  					client_payload: {
   103  						type: "unity"
   104  						payload: {
   105  							versions: """
   106  							"\(_cueVersionRef)"
   107  							"""
   108  						}
   109  					}
   110  				}
   111  			},
   112  		]
   113  	}
   114  }