Skip to content

Commit

Permalink
Enable auto-publish and update dependencies (#248)
Browse files Browse the repository at this point in the history
Review with whitespace diffing off for an easier time.


https://github.com/google-github-actions/setup-cloud-sdk/pull/248/files?w=1
  • Loading branch information
sethvargo authored Apr 15, 2024
1 parent 780e1c9 commit e3f4304
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 230 deletions.
144 changes: 72 additions & 72 deletions .github/workflows/compile-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,80 +17,80 @@ jobs:
runs-on: 'ubuntu-latest'

steps:
- uses: 'actions/checkout@v4'

- uses: 'actions/setup-go@v4'
with:
go-version: '1.20'

- name: 'Get versions list'
run: |-
mkdir -p ./data
go run ./cmd/compile-versions/main.go > ./data/versions.json
echo "Computed versions:"
cat ./data/versions.json
- id: 'updates'
name: 'Update versions list'
run: |-
if git diff --exit-code ./data/versions.json; then
echo "No changes"
exit 0
fi
echo "had_changes=true" >> ${GITHUB_OUTPUT}
git config user.name "google-github-actions-bot"
git config user.email "[email protected]"
git checkout -b "${{ env.PR_BRANCH }}"
git add ./data/versions.json
git commit -m "Update gcloud versions ($(date --iso-8601=h))"
git push -f origin "${{ env.PR_BRANCH }}"
- name: 'Create Pull Request'
if: steps.updates.outputs.had_changes == 'true'
uses: 'actions/github-script@v6'
with:
github-token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
script: |-
const baseBranch = `${{ github.ref_name }}`;
const prBranch = `${{ env.PR_BRANCH }}`;
const prBody = `Update latest gcloud versions`;
try {
const listResponse = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: `open`,
head: `${context.repo.owner}:${prBranch}`,
base: baseBranch,
});
core.isDebug() && console.log(listResponse);
if(!listResponse.data.length) {
const createResponse = await github.rest.pulls.create({
- uses: 'actions/checkout@v4'

- uses: 'actions/setup-go@v5'
with:
go-version: '1.22'

- name: 'Get versions list'
run: |-
mkdir -p ./data
go run ./cmd/compile-versions/main.go > ./data/versions.json
echo "Computed versions:"
cat ./data/versions.json
- id: 'updates'
name: 'Update versions list'
run: |-
if git diff --exit-code ./data/versions.json; then
echo "No changes"
exit 0
fi
echo "had_changes=true" >> ${GITHUB_OUTPUT}
git config user.name "google-github-actions-bot"
git config user.email "[email protected]"
git checkout -b "${{ env.PR_BRANCH }}"
git add ./data/versions.json
git commit -m "Update gcloud versions ($(date --iso-8601=h))"
git push -f origin "${{ env.PR_BRANCH }}"
- name: 'Create Pull Request'
if: steps.updates.outputs.had_changes == 'true'
uses: 'actions/github-script@v7'
with:
github-token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
script: |-
const baseBranch = `${{ github.ref_name }}`;
const prBranch = `${{ env.PR_BRANCH }}`;
const prBody = `Update latest gcloud versions`;
try {
const listResponse = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Update gcloud versions`,
body: prBody,
head: prBranch,
state: `open`,
head: `${context.repo.owner}:${prBranch}`,
base: baseBranch,
});
core.info(`Created PR #${createResponse.data.number} at ${createResponse.data.html_url}`);
} else {
const updateResponse = await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: listResponse.data[0].number,
title: `Update gcloud versions`,
body: prBody,
});
core.info(`Updated PR #${updateResponse.data.number} at ${updateResponse.data.html_url}`);
core.isDebug() && console.log(listResponse);
if(!listResponse.data.length) {
const createResponse = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Update gcloud versions`,
body: prBody,
head: prBranch,
base: baseBranch,
});
core.info(`Created PR #${createResponse.data.number} at ${createResponse.data.html_url}`);
} else {
const updateResponse = await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: listResponse.data[0].number,
title: `Update gcloud versions`,
body: prBody,
});
core.info(`Updated PR #${updateResponse.data.number} at ${updateResponse.data.html_url}`);
}
} catch(err) {
console.error(err);
core.setFailed(`Failed to create pull request: ${err}`);
}
} catch(err) {
console.error(err);
core.setFailed(`Failed to create pull request: ${err}`);
}
22 changes: 20 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ on:

jobs:
release:
if: "startsWith(github.event.head_commit.message, 'Release: v')"
name: 'Release'
if: |-
${{ startsWith(github.event.head_commit.message, 'Release: v') }}
uses: 'google-github-actions/.github/.github/workflows/release.yml@v0'

publish:
needs:
- 'release'
runs-on: 'ubuntu-latest'

steps:
- uses: 'actions/checkout@v4'

- uses: 'actions/setup-node@v4'
with:
node-version: '20.x'
registry-url: 'https://wombat-dressing-room.appspot.com/'

- env:
NODE_AUTH_TOKEN: '${{ secrets.NODE_AUTH_TOKEN }}'
run: |-
npm publish
38 changes: 18 additions & 20 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,28 @@ jobs:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-2022'
- 'macos-latest'
node:
- '20.x'
- 'ubuntu-latest'
- 'windows-2022'
- 'macos-latest'
runs-on: '${{ matrix.os }}'

steps:
- uses: 'actions/checkout@v4'
- uses: 'actions/checkout@v4'

- uses: 'actions/setup-node@v4'
with:
node-version: '${{ matrix.node }}'
- uses: 'actions/setup-node@v4'
with:
node-version: '20.x'

- name: 'npm build'
run: 'npm ci && npm run build'
- name: 'npm build'
run: 'npm ci && npm run build'

- name: 'npm lint'
# There's no need to run the linter for each operating system, since it
# will find the same thing 9x and clog up the PR review.
if: ${{ matrix.os == 'ubuntu-latest' }}
run: 'npm run lint'
- name: 'npm lint'
# There's no need to run the linter for each operating system, since it
# will find the same thing 9x and clog up the PR review.
if: ${{ matrix.os == 'ubuntu-latest' }}
run: 'npm run lint'

- name: 'npm test'
env:
SERVICE_ACCOUNT_KEY_JSON: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
run: 'npm run test'
- name: 'npm test'
env:
SERVICE_ACCOUNT_KEY_JSON: '${{ secrets.SERVICE_ACCOUNT_KEY_JSON }}'
run: 'npm run test'
55 changes: 31 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
module github.com/google-github-actions/setup-cloud-sdk

go 1.20
go 1.22

require (
cloud.google.com/go/storage v1.31.0
github.com/maruel/natural v1.1.0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
google.golang.org/api v0.126.0
cloud.google.com/go/storage v1.40.0
github.com/maruel/natural v1.1.1
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8
google.golang.org/api v0.172.0
)

require (
cloud.google.com/go v0.110.2 // indirect
cloud.google.com/go/compute v1.19.3 // indirect
cloud.google.com/go v0.112.2 // indirect
cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.15.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.56.3 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20240412170617-26222e5d3d56 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240412170617-26222e5d3d56 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240412170617-26222e5d3d56 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
Loading

0 comments on commit e3f4304

Please sign in to comment.