-
Notifications
You must be signed in to change notification settings - Fork 273
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 release steps to the buildkite pipeline #544
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
agents: | ||
queue: hosted | ||
|
||
steps: | ||
- command: "auto/release-gem" | ||
label: ":rubygems:" | ||
key: release | ||
env: | ||
RELEASE_VERSION: "__TEMPLATE__" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
echo "--- Request OIDC token" | ||
|
||
export BUILDKITE_OIDC_TOKEN="$(buildkite-agent oidc request-token --audience "rubygems.org" --lifetime 60)" | ||
|
||
echo "${BUILDKITE_OIDC_TOKEN}" | head -c 20 | ||
echo | ||
|
||
echo "--- Request rubygems token" | ||
|
||
RUBYGEMS_ROLE="rg_oidc_akr_xoy8sqmj25t8ok4rn5sq" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks secret, but not actually that secret |
||
|
||
echo "{\"jwt\":\"${BUILDKITE_OIDC_TOKEN}\"}" | head -c 30 | ||
echo | ||
|
||
#curl -v -s -X POST \ | ||
# --fail-with-body \ | ||
# -H "Content-Type: application/json" \ | ||
# --data "{\"jwt\":\"${BUILDKITE_OIDC_TOKEN}\"}" \ | ||
# "https://rubygems.org/api/v1/oidc/api_key_roles/${RUBYGEMS_ROLE}/assume_role" | ||
|
||
#--fail-with-body \ | ||
RESPONSE=$(curl -s -X POST \ | ||
-H "Content-Type: application/json" \ | ||
--data "{\"jwt\":\"${BUILDKITE_OIDC_TOKEN}\"}" \ | ||
"https://rubygems.org/api/v1/oidc/api_key_roles/${RUBYGEMS_ROLE}/assume_role") | ||
|
||
ERROR_MESSAGE=$(echo "${RESPONSE}" | jq -r .error) | ||
GEM_HOST_API_KEY==$(echo "${RESPONSE}" | jq -r .rubygems_api_key) | ||
|
||
if [ "${ERROR_MESSAGE}" != "null" ]; then | ||
echo "Requesting API token failed" | ||
echo "ERROR: ${ERROR_MESSAGE}" | ||
exit 1 | ||
fi | ||
|
||
echo "${GEM_HOST_API_KEY}" | head -c 10 | ||
|
||
echo "--- Build and publish gem" | ||
|
||
cd $(dirname $0)/.. | ||
|
||
# apt-get update --assume-yes && apt-get install --assume-yes ruby-rubygems | ||
# gem build pdf-reader.gemspec | ||
# GEM_HOST_API_KEY="${GEM_HOST_API_KEY}" gem push "pdf-reader-${RELEASE_VERSION}.gem" | ||
|
||
docker run -it -v "${PWD}:/work" -w /work -e GEM_HOST_API_KEY="${GEM_HOST_API_KEY}" ruby:3.4-slim bash -c "gem build pdf-reader.gemspec && gem push \"pdf-reader-${RELEASE_VERSION}.gem\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could go back to using the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
#if [ "${BUILDKITE_BRANCH}" != "main" ]; then | ||
# echo "Non main branch, skipping release" | ||
# exit | ||
#fi | ||
|
||
GEMSPEC_PATH="$(dirname $0)/../pdf-reader.gemspec" | ||
|
||
RELEASE_VERSION=$(grep "spec.version =" $GEMSPEC_PATH | sed -r 's/.*spec.version = "([^"]+)".*/\1/') | ||
|
||
echo "version: ${RELEASE_VERSION}" | ||
|
||
if [ $(curl -s -o /dev/null -w "%{http_code}" https://rubygems.org/api/v2/rubygems/pdf-reader/versions/${RELEASE_VERSION}.json) == "200" ]; then | ||
echo "Gem version ${RELEASE_VERSION} already found on rubygems, skipping release" | ||
exit | ||
fi | ||
|
||
export RELEASE_VERSION | ||
|
||
cat $(dirname $0)/../.buildkite/pipeline.release.yml | sed -r 's/__TEMPLATE__/${RELEASE_VERSION}/' | buildkite-agent pipeline upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncomment this before merging