summaryrefslogtreecommitdiff
path: root/.gcp/release.yaml
blob: ad2c373a93912e9d3c939e1d01b07218ff83e875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
steps:
  # Step 1: Install root dependencies (includes workspaces)
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Install Dependencies'
    entrypoint: 'npm'
    args: ['install']

  # Step 2: Update version in root package.json
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Set version in workspace root'
    entrypoint: 'bash'
    args:
      - -c # Use bash -c to allow for command substitution and string manipulation
      - |
        current_version=$(npm pkg get version | sed 's/"//g')
        if [ "$_OFFICIAL_RELEASE" = "true" ]; then
          new_version="$current_version"
        else
          new_version="${current_version}-rc.$_REVISION"
        fi
        npm pkg set "version=${new_version}"
        echo "Set root package.json version to: ${new_version}"

  # Step 3: Binds the package versions to the version in the repo root's package.json
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Bind package versions to workspace root'
    entrypoint: 'npm'
    args: ['run', 'prerelease:dev'] # This will run prerelease:version and prerelease:deps

  # Step 4: Authenticate for Docker (so we can push images to the artifact registry)
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Authenticate docker'
    entrypoint: 'npm'
    args: ['run', 'auth']

  # Step 5: Build workspace packages
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Build packages'
    entrypoint: 'npm'
    args: ['run', 'build:packages']

  # Step 6: Prepare CLI package.json for publishing
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Prepare @google/gemini-cli and @google/gemini-cli-core packages'
    entrypoint: 'npm'
    args: ['run', 'prepare:packages']
    env:
      - 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
      - 'SANDBOX_IMAGE_REGISTRY=$_SANDBOX_IMAGE_REGISTRY'
      - 'SANDBOX_IMAGE_NAME=$_SANDBOX_IMAGE_NAME'

  # Step 7: Build sandbox container image
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Build sandbox Docker image'
    entrypoint: 'npm'
    args: ['run', 'build:sandbox:fast']
    env:
      - 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
      - 'SANDBOX_IMAGE_REGISTRY=$_SANDBOX_IMAGE_REGISTRY'
      - 'SANDBOX_IMAGE_NAME=$_SANDBOX_IMAGE_NAME'

  # Step 8: Publish sandbox container image
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Publish sandbox Docker image'
    entrypoint: 'npm'
    args: ['run', 'publish:sandbox']
    env:
      - 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
      - 'SANDBOX_IMAGE_REGISTRY=$_SANDBOX_IMAGE_REGISTRY'
      - 'SANDBOX_IMAGE_NAME=$_SANDBOX_IMAGE_NAME'

  # Pre-Step 9: authenticate to our intermediate npm registry
  # NOTE: when running locally, run this instead (from the `packages/core` directory):
  #   - `npm login --registry https://wombat-dressing-room.appspot.com`
  #   - use a 24hr token
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Setup @google/gemini-cli-core auth token for publishing'
    entrypoint: 'bash'
    args:
      - -c
      - |
        echo "//wombat-dressing-room.appspot.com/:_authToken=$$CORE_PACKAGE_PUBLISH_TOKEN" > $$HOME/.npmrc
    secretEnv: ['CORE_PACKAGE_PUBLISH_TOKEN']

  # Step 9: Publish @google/gemini-cli-core to NPM
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Publish @google/gemini-cli-core package'
    entrypoint: 'bash'
    args:
      - -c
      - |
        if [ "$_OFFICIAL_RELEASE" = "true" ]; then
          npm publish --workspace=@google/gemini-cli-core --tag=latest
        else
          npm publish --workspace=@google/gemini-cli-core --tag=rc
        fi
    env:
      - 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
      - 'SANDBOX_IMAGE_REGISTRY=$_SANDBOX_IMAGE_REGISTRY'
      - 'SANDBOX_IMAGE_NAME=$_SANDBOX_IMAGE_NAME'

  # Pre-Step 10: authenticate to our intermediate npm registry
  # NOTE: when running locally, run this instead (from the `packages/cli` directory)
  #   - `npm login --registry https://wombat-dressing-room.appspot.com`
  #   - use a 24hr token
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Setup @google/gemini-cli auth token for publishing'
    entrypoint: 'bash'
    args:
      - -c
      - |
        echo "//wombat-dressing-room.appspot.com/:_authToken=$$CLI_PACKAGE_PUBLISH_TOKEN" > $$HOME/.npmrc
    secretEnv: ['CLI_PACKAGE_PUBLISH_TOKEN']

  # Step 10: Publish @google/gemini-cli to NPM
  - name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
    id: 'Publish @google/gemini-cli package'
    entrypoint: 'bash'
    args:
      - -c
      - |
        if [ "$_OFFICIAL_RELEASE" = "true" ]; then
          npm publish --workspace=@google/gemini-cli --tag=latest
        else
          npm publish --workspace=@google/gemini-cli --tag=rc
        fi
    env:
      - 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
      - 'SANDBOX_IMAGE_REGISTRY=$_SANDBOX_IMAGE_REGISTRY'
      - 'SANDBOX_IMAGE_NAME=$_SANDBOX_IMAGE_NAME'

options:
  defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET
  dynamicSubstitutions: true

availableSecrets:
  secretManager:
    - versionName: ${_CLI_PACKAGE_WOMBAT_TOKEN_RESOURCE_NAME}
      env: 'CLI_PACKAGE_PUBLISH_TOKEN'
    - versionName: ${_CORE_PACKAGE_WOMBAT_TOKEN_RESOURCE_NAME}
      env: 'CORE_PACKAGE_PUBLISH_TOKEN'

substitutions:
  _REVISION: '0'
  _OFFICIAL_RELEASE: 'false'
  _CONTAINER_TOOL: 'docker'
  _SANDBOX_IMAGE_REGISTRY: ''
  _SANDBOX_IMAGE_NAME: ''
  _CLI_PACKAGE_WOMBAT_TOKEN_RESOURCE_NAME: ''
  _CORE_PACKAGE_WOMBAT_TOKEN_RESOURCE_NAME: ''