Skip to content

Commit 20d6573

Browse files
committed
internal/ci: pass access token to releaser step
A previous CL (https://cuelang.org/cl/1201986) started using the Central Registry for github actions schemas, but the `cue cmd release` command run in `internal/ci` also depends on some of the same CUE code, so provide the token to that step too, making it easily reusable if we find more steps that need it. Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ibb4a8b0cbb1bb2af2e8797f1b934fcbae410aa58 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202051 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 992127e commit 20d6573

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

.github/workflows/release.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ jobs:
8383
version: v2.2.0
8484
- name: Run GoReleaser with CUE
8585
env:
86+
CUE_LOGINS: ${{ secrets.NOTCUECKOO_CUE_LOGINS }}
8687
GITHUB_TOKEN: ${{ secrets.CUECKOO_GITHUB_PAT }}
87-
run: cue cmd release
88+
run: |-
89+
export CUE_CONFIG_DIR=$(mktemp -d)
90+
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
91+
cue cmd release
8892
working-directory: ./internal/ci/goreleaser
8993
- name: Re-test cuelang.org
9094
if: startsWith(github.ref, 'refs/tags/v')

internal/ci/github/logins.cue

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2024 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+
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions"
19+
)
20+
21+
// _registryReadOnlyAccessStep defines a step that configures
22+
// a read-only Central Registry access credential. The actual
23+
// command should be placed in the _run field.
24+
_registryReadOnlyAccessStep: githubactions.#Step & {
25+
_run!: string
26+
env: {
27+
// Note: this token has read-only access to the registry
28+
// and is used only because we need some credentials
29+
// to pull dependencies from the Central Registry.
30+
CUE_LOGINS: "${{ secrets.NOTCUECKOO_CUE_LOGINS }}"
31+
}
32+
run: """
33+
export CUE_CONFIG_DIR=$(mktemp -d)
34+
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
35+
\(_run)
36+
"""
37+
}

internal/ci/github/release.cue

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ workflows: release: _repo.bashWorkflow & {
7979
version: _repo.goreleaserVersion
8080
}
8181
},
82-
githubactions.#Step & {
82+
_registryReadOnlyAccessStep & {
8383
// Note that the logic for what gets run at release time
8484
// is defined with the release command in CUE.
8585
name: "Run GoReleaser with CUE"
8686
env: GITHUB_TOKEN: "${{ secrets.CUECKOO_GITHUB_PAT }}"
87-
run: "cue cmd release"
87+
_run: "cue cmd release"
8888
"working-directory": "./internal/ci/goreleaser"
8989
},
9090
_repo.repositoryDispatch & {

internal/ci/github/trybot.cue

+2-12
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,9 @@ workflows: trybot: _repo.bashWorkflow & {
108108
// work.
109109
_isLatestLinux: "(\(goVersion) == '\(_repo.latestGo)' && \(matrixRunner) == '\(_repo.linuxMachine)')"
110110

111-
_goGenerate: githubactions.#Step & {
111+
_goGenerate: _registryReadOnlyAccessStep & {
112112
name: "Generate"
113-
env: {
114-
// Note: this token has read-only access to the registry
115-
// and is used only because we need some credentials
116-
// to pull dependencies from the Central Registry.
117-
CUE_LOGINS: "${{ secrets.NOTCUECKOO_CUE_LOGINS }}"
118-
}
119-
run: """
120-
export CUE_CONFIG_DIR=$(mktemp -d)
121-
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
122-
go generate ./...
123-
"""
113+
_run: "go generate ./..."
124114
// The Go version corresponds to the precise version specified in
125115
// the matrix. Skip windows for now until we work out why re-gen is flaky
126116
if: _isLatestLinux

0 commit comments

Comments
 (0)