Skip to content

Commit

Permalink
chore: replace github token tool (#2943)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmenezes committed May 10, 2024
1 parent fc15bea commit 7d13550
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 215 deletions.
10 changes: 1 addition & 9 deletions build/ci/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ functions:
set -Eeou pipefail
export PATH="$ADD_PATH:$PATH"
curl -sfL https://github.com/gotestyourself/gotestsum/releases/download/v${gotestsum_ver}/gotestsum_${gotestsum_ver}_linux_amd64.tar.gz | tar zx
"install podman":
- command: subprocess.exec
type: setup
params:
working_dir: src/github.com/mongodb/mongodb-atlas-cli/bin
binary: ../build/ci/install_podman.sh
"setup operator":
command: subprocess.exec
type: setup
Expand Down Expand Up @@ -1125,7 +1119,6 @@ tasks:
patch_optional: true
commands:
- func: "install gotestsum"
- func: "install podman"
- command: shell.exec
type: setup
params:
Expand Down Expand Up @@ -1159,7 +1152,6 @@ tasks:
patch_optional: true
commands:
- func: "install gotestsum"
- func: "install podman"
- command: shell.exec
type: setup
params:
Expand Down Expand Up @@ -1327,7 +1319,7 @@ buildvariants:
- name: e2e_local_deployments
display_name: "E2E Local Deployments Tests"
run_on:
- rhel80-small
- rhel90-small
expansions:
<<: *go_linux_version
tasks:
Expand Down
29 changes: 0 additions & 29 deletions build/ci/install_podman.sh

This file was deleted.

1 change: 0 additions & 1 deletion build/ci/library_owners.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"github.com/aws/aws-sdk-go-v2/config": "mongocli",
"github.com/aws/aws-sdk-go-v2/credentials": "mongocli",
"github.com/aws/aws-sdk-go-v2/service/kms": "mongocli",
"github.com/bradleyfalzon/ghinstallation/v2": "mongocli",
"github.com/briandowns/spinner": "mongocli",
"github.com/evergreen-ci/shrub": "mongocli",
"github.com/go-test/deep": "mongocli",
Expand Down
27 changes: 24 additions & 3 deletions build/ci/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ variables:
env:
<<: *go_env
functions:
"install gh-token":
- command: shell.exec
type: setup
params:
working_dir: src/github.com/mongodb/mongodb-atlas-cli/bin
script: |
set -Eeou pipefail
curl --output gh-token -sfL https://github.com/Link-/gh-token/releases/download/v2.0.1/linux-amd64
chmod 755 ./gh-token
"install goreleaser":
- command: shell.exec
type: setup
Expand Down Expand Up @@ -278,8 +287,8 @@ tasks:
commands:
- func: "generate notices"
- func: "install goreleaser"
- func: "install podman"
- func: "install macos notarization service"
- func: "install gh-token"
- command: subprocess.exec
type: test
params:
Expand All @@ -292,6 +301,18 @@ tasks:
BUCKET: mongodb-mongocli-build
unstable: ${unstable}
binary: build/package/download-win-binaries.sh
- command: subprocess.exec
type: test
params:
include_expansions_in_env:
- unstable
env:
ARTIFACTORY_USERNAME: ${artifactory_username}
ARTIFACTORY_PASSWORD: ${artifactory_password}
GRS_USERNAME: ${garasign_username}
GRS_PASSWORD: ${garasign_password}
working_dir: src/github.com/mongodb/mongodb-atlas-cli
binary: build/package/windows_notarize.sh
- func: "package"
vars:
unstable: ${unstable}
Expand Down Expand Up @@ -410,7 +431,7 @@ buildvariants:
- name: goreleaser_atlascli_snapshot
display_name: "Packaging AtlasCLI (goreleaser)"
run_on:
- rhel80-small
- rhel90-small
expansions:
<<: *go_linux_version
server_version: "4.4.0-rc3"
Expand All @@ -436,7 +457,7 @@ buildvariants:
display_name: "Release AtlasCLI (goreleaser)"
git_tag_only: true
run_on:
- rhel80-small
- rhel90-small
expansions:
<<: *go_linux_version
server_version: "4.4.0-rc3"
Expand Down
6 changes: 0 additions & 6 deletions build/package/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ builds:
goamd64: [v1]
prebuilt:
path: ./bin/atlas.exe
hooks:
post:
- cmd: ./build/package/windows_notarize.sh
env:
- VERSION={{ .Version }}
output: true
gomod: # https://goreleaser.com/customization/verifiable_builds/
# Proxy a module from proxy.golang.org, making the builds verifiable.
# This will only be effective if running against a tag. Snapshots will ignore
Expand Down
5 changes: 4 additions & 1 deletion build/package/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export GORELEASER_KEY=${goreleaser_key:?}
export VERSION_GIT

echo "$GITHUB_APP_PEM" > app.pem
GITHUB_TOKEN="$(go run ./tools/github-token -pem app.pem -app_id "$GITHUB_APP_ID" -owner 'mongodb' -repo 'mongodb-atlas-cli')"
GITHUB_INSTALLATION_ID=$(gh-token installations --app-id "$GITHUB_APP_ID" --key ./app.pem | jq '.[] | select(.account.login == "mongodb") | .id' | head -1)
GITHUB_TOKEN=$(gh-token generate --app-id "$GITHUB_APP_ID" --key ./app.pem --installation-id "$GITHUB_INSTALLATION_ID" -t)
rm -rf app.pem
export GITHUB_TOKEN

Expand All @@ -40,6 +41,8 @@ else
./bin/goreleaser --config "build/package/.goreleaser.yml" --rm-dist --release-notes "CHANGELOG.md" -p 1
fi

gh-token revoke -t "$GITHUB_TOKEN"

# check that the notarization service signed the mac binaries
SIGNED_FILE_NAME=mongodb-atlas-cli_macos_signed.zip
if [[ -f "dist/$SIGNED_FILE_NAME" ]]; then
Expand Down
8 changes: 7 additions & 1 deletion build/package/windows_notarize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@

set -Eeou pipefail

VERSION_GIT="$(git tag --list "atlascli/v*" --sort=taggerdate | tail -1 | cut -d "v" -f 2)"
VERSION_NAME="$VERSION_GIT"
if [[ "${unstable-}" == "-unstable" ]]; then
VERSION_NAME="$VERSION_GIT-next"
fi

EXE_FILE="bin/atlas.exe"
MSI_FILE="bin/mongodb-atlas-cli_${VERSION}_windows_x86_64.msi"
MSI_FILE="bin/mongodb-atlas-cli_${VERSION_NAME}_windows_x86_64.msi"

if [[ -f "$EXE_FILE" && -f "$MSI_FILE" ]]; then
echo "${ARTIFACTORY_PASSWORD}" | podman login --password-stdin --username "${ARTIFACTORY_USERNAME}" artifactory.corp.mongodb.com
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.27.11
github.com/aws/aws-sdk-go-v2/credentials v1.17.11
github.com/aws/aws-sdk-go-v2/service/kms v1.31.0
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0
github.com/briandowns/spinner v1.23.0
github.com/creack/pty v1.1.21
github.com/denisbrodbeck/machineid v1.0.1
Expand Down Expand Up @@ -98,7 +97,6 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-github/v60 v60.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 h1:cwIxeBttqPN3qkaAjcEcsh8NYr8n
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6/go.mod h1:FZf1/nKNEkHdGGJP/cI2MoIMquumuRK6ol3QQJNDxmw=
github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q=
github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 h1:XWuWBRFEpqVrHepQob9yPS3Xg4K3Wr9QCx4fu8HbUNg=
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0/go.mod h1:qoGA4DxWPaYTgVCrmEspVSjlTu4WYAiSxMIhorMRXXc=
github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A=
github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -169,8 +167,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v60 v60.0.0 h1:oLG98PsLauFvvu4D/YPxq374jhSxFYdzQGNCyONLfn8=
github.com/google/go-github/v60 v60.0.0/go.mod h1:ByhX2dP9XT9o/ll2yXAu2VD8l5eNVg8hD4Cr0S/LmQk=
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
Expand Down
84 changes: 0 additions & 84 deletions tools/github-token/apix_bot.go

This file was deleted.

75 changes: 0 additions & 75 deletions tools/github-token/main.go

This file was deleted.

0 comments on commit 7d13550

Please sign in to comment.