Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying version constraints #612

Merged
merged 1 commit into from Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/integration.yml
Expand Up @@ -38,6 +38,18 @@ jobs:
- name: 'Build'
run: 'npm ci && npm run build'

# No installation
- name: 'Install constraint'
uses: './'
with:
skip_install: true

# Constraint installation
- name: 'Install constraint'
uses: './'
with:
version: '>= 1.0.0'

# Default installation
- name: 'Install version'
uses: './'
Expand Down
41 changes: 37 additions & 4 deletions README.md
Expand Up @@ -41,6 +41,8 @@ jobs:

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'

- name: 'Use gcloud CLI'
run: 'gcloud info'
Expand All @@ -50,13 +52,42 @@ jobs:

### Cloud SDK inputs

- `version`: (Optional) A string representing the version of the Cloud SDK
(`gcloud`) to install (e.g. `"290.0.1"`). The default value is "latest",
which will install the latest available Cloud SDK version.
- `skip_install`: (Optional) Skip the `gcloud` installation and use the
[system-installed gcloud][github-runners] instead. This can dramatically
improve workflow speeds at the expense of a slightly older gcloud version.
Setting this to `true` ignores any value for the `version` input. Even if
installation is skipped, this GitHub Action will still configure any
components or project metadata. The default value is `false`.

- `version`: (Optional) A string representing the version or version
constraint of the Cloud SDK (`gcloud`) to install (e.g. `"290.0.1"` or `">=
197.0.1"`). The default value is `"latest"`, which will always download and
install the latest available Cloud SDK version.

```yaml
- uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 416.0.0'
```

If there is no installed `gcloud` version that matches the given constraint,
this GitHub Action will download and install the latest available version
that still matches the constraint.

**Warning!** Workload Identity Federation requires version
[363.0.0](https://cloud.google.com/sdk/docs/release-notes#36300_2021-11-02)
or newer.
or newer. If you need support for Workload Identity Federation, specify your
version constraint as such:

```yaml
- uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'
```

You are responsible for ensuring the `gcloud` version matches the features
and components required. See the [gcloud release
notes][gcloud-release-notes] for a full list of versions.

- `project_id`: (Optional) Project ID (**not** project _number_) of the Google
Cloud project. If provided, this will configure the `gcloud` CLI to use that
Expand Down Expand Up @@ -233,3 +264,5 @@ See [LICENSE](LICENSE).
[sa-iam-docs]: https://cloud.google.com/iam/docs/service-accounts
[sa]: https://cloud.google.com/iam/docs/creating-managing-service-accounts
[wif]: https://cloud.google.com/iam/docs/workload-identity-federation
[github-runners]: https://github.com/actions/runner-images
[gcloud-release-notes]: https://cloud.google.com/sdk/docs/release-notes
18 changes: 13 additions & 5 deletions action.yml
Expand Up @@ -19,20 +19,28 @@ description: |-
Adds the `gcloud` CLI command to the $PATH.

inputs:
skip_install:
description: |-
Skip installation of the gcloud SDK and use the system-supplied version
instead. The "version" input will be ignored.
default: false
required: false

version:
description: |-
Version of the gcloud SDK to install. If unspecified or set to "latest",
the latest available gcloud SDK version for the target platform will be
installed. Example: "290.0.1".
default: latest
Version or version constraint of the gcloud SDK to install. If
unspecified, it will accept any installed version of the gcloud SDK. If
set to "latest", it will download the latest available SDK. If set to a
version constraint, it will download the latest available version that
matches the constraint. Examples: "290.0.1" or ">= 197.0.1".
default: 'latest'
required: false

project_id:
description: |-
ID of the Google Cloud project. If provided, this will configure gcloud to
use this project ID by default for commands. Individual commands can still
override the project using the --project flag which takes precedence.
default: null
required: false

install_components:
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js

Large diffs are not rendered by default.