cuelang.org/go@v0.13.0/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  	"cue.dev/x/githubactions"
    20  )
    21  
    22  // _cueVersionRef is a workflow job-runtime expression that evaluates to the
    23  // git tag (version) that is being released. Defining as a "constant" here for
    24  // re-use below
    25  _cueVersionRef: "${GITHUB_REF##refs/tags/}"
    26  
    27  // The release workflow
    28  workflows: release: _repo.bashWorkflow & {
    29  
    30  	name: "Release"
    31  
    32  	// We only want a single release happening at a time to avoid
    33  	// race conditions on updating the latest docker images or
    34  	// homebrew tags.
    35  	concurrency: "release"
    36  
    37  	on: push: {
    38  		tags: [_repo.releaseTagPattern, "!" + _repo.zeroReleaseTagPattern]
    39  		branches: list.Concat([[_repo.testDefaultBranch], _repo.protectedBranchPatterns])
    40  	}
    41  	jobs: goreleaser: {
    42  		"runs-on": _repo.linuxMachine
    43  		if:        "${{github.repository == '\(_repo.githubRepositoryPath)'}}"
    44  
    45  		let installGo = _repo.installGo & {
    46  			#setupGo: with: "go-version": _repo.pinnedReleaseGo
    47  			_
    48  		}
    49  		steps: [
    50  			for v in _repo.checkoutCode {v},
    51  			for v in installGo {v},
    52  			githubactions.#Step & {
    53  				name: "Setup qemu"
    54  				uses: "docker/setup-qemu-action@v3"
    55  			},
    56  			githubactions.#Step & {
    57  				name: "Set up Docker Buildx"
    58  				uses: "docker/setup-buildx-action@v3"
    59  			},
    60  			githubactions.#Step & {
    61  				name: "Docker Login"
    62  				uses: "docker/login-action@v3"
    63  				with: {
    64  					registry: "docker.io"
    65  					username: "cueckoo"
    66  					password: "${{ secrets.CUECKOO_DOCKER_PAT }}"
    67  				}
    68  			},
    69  
    70  			_repo.loginCentralRegistry,
    71  
    72  			githubactions.#Step & {
    73  				name: "Install GoReleaser"
    74  				uses: "goreleaser/goreleaser-action@v5"
    75  				with: {
    76  					"install-only": true
    77  					version:        _repo.goreleaserVersion
    78  				}
    79  			},
    80  			{
    81  				// Note that the logic for what gets run at release time
    82  				// is defined with the release command in CUE.
    83  				name: "Run GoReleaser with CUE"
    84  				env: GITHUB_TOKEN: "${{ secrets.CUECKOO_GITHUB_PAT }}"
    85  				run:                 "\(_repo.cueCommand) cmd release"
    86  				"working-directory": "./internal/ci/goreleaser"
    87  			},
    88  			_repo.repositoryDispatch & {
    89  				name:                  "Re-test cuelang.org"
    90  				if:                    _repo.isReleaseTag
    91  				#githubRepositoryPath: _repo.cuelangRepositoryPath
    92  				#arg: {
    93  					event_type: "Re-test post release of \(_cueVersionRef)"
    94  				}
    95  			},
    96  			_repo.repositoryDispatch & {
    97  				name:                          "Trigger unity build"
    98  				if:                            _repo.isReleaseTag
    99  				#githubRepositoryPath:         _repo.unityRepositoryPath
   100  				#botGitHubUserTokenSecretsKey: "PORCUEPINE_GITHUB_PAT"
   101  				#arg: {
   102  					event_type: "Check against CUE \(_cueVersionRef)"
   103  					client_payload: {
   104  						type: "unity"
   105  						payload: {
   106  							versions: """
   107  							"\(_cueVersionRef)"
   108  							"""
   109  						}
   110  					}
   111  				}
   112  			},
   113  		]
   114  	}
   115  }