chore(ci): Update release workflow for shell escaping (#17560)

pull/17540/head^2
Paul Rogers 1 year ago committed by GitHub
parent e89fd41a6a
commit c129024d63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/jsonnetfile.json
  2. 4
      .github/jsonnetfile.lock.json
  3. 30
      .github/vendor/github.com/grafana/loki-release/workflows/release.libsonnet
  4. 6
      .github/workflows/minor-release-pr.yml
  5. 6
      .github/workflows/patch-release-pr.yml
  6. 24
      .github/workflows/release.yml

@ -8,7 +8,7 @@
"subdir": "workflows"
}
},
"version": "26d43e7333c8e5d5f6f407fce758f7c0e6363f95"
"version": "c81bbf8aae70c6899796068184e3406caaddf27c"
}
],
"legacyImports": true

@ -8,8 +8,8 @@
"subdir": "workflows"
}
},
"version": "26d43e7333c8e5d5f6f407fce758f7c0e6363f95",
"sum": "5+tR36ZnDOHjQLqiwsKu0emb/yp65qBSrFzLWIPGcRU="
"version": "c81bbf8aae70c6899796068184e3406caaddf27c",
"sum": "UcFLhQVmAWE8HdInfk9VRU4lrDAkAB4QcS9XTO4Nnus="
}
],
"legacyImports": false

@ -47,12 +47,12 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
--manifest-file .release-please-manifest.json \
--pull-request-footer "%s" \
--pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \
--release-as "$OUTPUTS_VERSION" \
--release-as "$(echo $OUTPUTS_VERSION | tr -d '"')" \
--release-type simple \
--repo-url "${{ env.RELEASE_REPO }}" \
--separate-pull-requests false \
--target-branch "$OUTPUTS_BRANCH" \
--token "$OUTPUTS_TOKEN" \
--target-branch "$(echo $OUTPUTS_BRANCH | tr -d '"')" \
--token "$(echo $OUTPUTS_TOKEN | tr -d '"')" \
--dry-run ${{ fromJSON(env.DRY_RUN) }}
||| % pullRequestFooter),
@ -104,7 +104,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
releaseStep('download binaries')
+ step.withRun(|||
echo "downloading binaries to $(pwd)/dist"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/dist .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/dist .
|||),
releaseStep('check if release exists')
@ -115,7 +115,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
})
+ step.withRun(|||
set +e
isDraft="$(gh release view --json="isDraft" --jq=".isDraft" $OUTPUTS_NAME 2>&1)"
isDraft="$(gh release view --json="isDraft" --jq=".isDraft" $(echo $OUTPUTS_NAME | tr -d '"') 2>&1)"
set -e
if [[ "$isDraft" == "release not found" ]]; then
echo "exists=false" >> $GITHUB_OUTPUT
@ -143,9 +143,9 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
--draft \
--release-type simple \
--repo-url "${{ env.RELEASE_REPO }}" \
--target-branch "$OUTPUTS_BRANCH" \
--token "$OUTPUTS_TOKEN" \
--shas-to-tag "$OUTPUTS_PR_NUMBER:${SHA}"
--target-branch "$(echo $OUTPUTS_BRANCH | tr -d '"')" \
--token "$(echo $OUTPUTS_TOKEN | tr -d '"')" \
--shas-to-tag "$(echo $OUTPUTS_PR_NUMBER | tr -d '"'):$(echo ${SHA} | tr -d '"')"
|||),
releaseStep('upload artifacts')
@ -155,7 +155,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
OUTPUTS_NAME: '${{ needs.shouldRelease.outputs.name }}',
})
+ step.withRun(|||
gh release upload --clobber $OUTPUTS_NAME dist/*
gh release upload --clobber $(echo $OUTPUTS_NAME | tr -d '"') dist/*
|||),
step.new('release artifacts', 'google-github-actions/upload-cloud-storage@386ab77f37fdf51c0e38b3d229fad286861cc0d0') // v2
@ -201,7 +201,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
})
+ step.withRun(|||
echo "downloading images to $(pwd)/images"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/images .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/images .
|||),
step.new('publish docker images', './lib/actions/push-images')
+ step.with({
@ -239,7 +239,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
})
+ step.withRun(|||
echo "downloading images to $(pwd)/plugins"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/plugins .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/plugins .
mkdir -p "release/%s"
||| % path),
step.new('publish docker driver', './lib/actions/push-images')
@ -272,7 +272,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
OUTPUTS_IS_LATEST: '${{ needs.createRelease.outputs.isLatest }}',
})
+ step.withRun(|||
gh release edit $OUTPUTS_NAME --draft=false --latest=$OUTPUTS_IS_LATEST
gh release edit $(echo $OUTPUTS_NAME | tr -d '"') --draft=false --latest=$(echo $OUTPUTS_IS_LATEST | tr -d '"')
|||),
]) + job.withOutputs({
name: '${{ needs.createRelease.outputs.name }}',
@ -330,15 +330,15 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https://
echo "branch_exists=true" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
else
echo "Creating branch: $BRANCH_NAME from tag: $OUTPUTS_NAME"
echo "Creating branch: $BRANCH_NAME from tag: $(echo $OUTPUTS_NAME | tr -d '"')"
# Create branch from the tag
git fetch --tags
git checkout "$OUTPUTS_BRANCH"
git checkout "$(echo $OUTPUTS_BRANCH | tr -d '"')"
git checkout -b $BRANCH_NAME
# explicity set the github app token to override the release branch protection
git remote set-url origin "https://x-access-token:${OUTPUTS_TOKEN}@github.com/${{ env.RELEASE_REPO }}"
git remote set-url origin "https://x-access-token:$(echo ${OUTPUTS_TOKEN} | tr -d '"')@github.com/${{ env.RELEASE_REPO }}"
git push -u origin $BRANCH_NAME
echo "branch_exists=false" >> $GITHUB_OUTPUT

@ -107,12 +107,12 @@ jobs:
--manifest-file .release-please-manifest.json \
--pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/${BUILD_ARTIFACTS_BUCKET}/${SHA}) of ${SHA}" \
--pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \
--release-as "$OUTPUTS_VERSION" \
--release-as "$(echo $OUTPUTS_VERSION | tr -d '"')" \
--release-type simple \
--repo-url "${{ env.RELEASE_REPO }}" \
--separate-pull-requests false \
--target-branch "$OUTPUTS_BRANCH" \
--token "$OUTPUTS_TOKEN" \
--target-branch "$(echo $OUTPUTS_BRANCH | tr -d '"')" \
--token "$(echo $OUTPUTS_TOKEN | tr -d '"')" \
--dry-run ${{ fromJSON(env.DRY_RUN) }}
working-directory: "lib"

@ -107,12 +107,12 @@ jobs:
--manifest-file .release-please-manifest.json \
--pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/${BUILD_ARTIFACTS_BUCKET}/${SHA}) of ${SHA}" \
--pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \
--release-as "$OUTPUTS_VERSION" \
--release-as "$(echo $OUTPUTS_VERSION | tr -d '"')" \
--release-type simple \
--repo-url "${{ env.RELEASE_REPO }}" \
--separate-pull-requests false \
--target-branch "$OUTPUTS_BRANCH" \
--token "$OUTPUTS_TOKEN" \
--target-branch "$(echo $OUTPUTS_BRANCH | tr -d '"')" \
--token "$(echo $OUTPUTS_TOKEN | tr -d '"')" \
--dry-run ${{ fromJSON(env.DRY_RUN) }}
working-directory: "lib"

@ -80,7 +80,7 @@ jobs:
- name: "download binaries"
run: |
echo "downloading binaries to $(pwd)/dist"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/dist .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/dist .
working-directory: "release"
- env:
GH_TOKEN: "${{ steps.github_app_token.outputs.token }}"
@ -89,7 +89,7 @@ jobs:
name: "check if release exists"
run: |
set +e
isDraft="$(gh release view --json="isDraft" --jq=".isDraft" $OUTPUTS_NAME 2>&1)"
isDraft="$(gh release view --json="isDraft" --jq=".isDraft" $(echo $OUTPUTS_NAME | tr -d '"') 2>&1)"
set -e
if [[ "$isDraft" == "release not found" ]]; then
echo "exists=false" >> $GITHUB_OUTPUT
@ -115,9 +115,9 @@ jobs:
--draft \
--release-type simple \
--repo-url "${{ env.RELEASE_REPO }}" \
--target-branch "$OUTPUTS_BRANCH" \
--token "$OUTPUTS_TOKEN" \
--shas-to-tag "$OUTPUTS_PR_NUMBER:${SHA}"
--target-branch "$(echo $OUTPUTS_BRANCH | tr -d '"')" \
--token "$(echo $OUTPUTS_TOKEN | tr -d '"')" \
--shas-to-tag "$(echo $OUTPUTS_PR_NUMBER | tr -d '"'):$(echo ${SHA} | tr -d '"')"
working-directory: "lib"
- env:
GH_TOKEN: "${{ steps.github_app_token.outputs.token }}"
@ -125,7 +125,7 @@ jobs:
id: "upload"
name: "upload artifacts"
run: |
gh release upload --clobber $OUTPUTS_NAME dist/*
gh release upload --clobber $(echo $OUTPUTS_NAME | tr -d '"') dist/*
working-directory: "release"
- if: "${{ fromJSON(env.PUBLISH_TO_GCS) }}"
name: "release artifacts"
@ -220,15 +220,15 @@ jobs:
echo "branch_exists=true" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
else
echo "Creating branch: $BRANCH_NAME from tag: $OUTPUTS_NAME"
echo "Creating branch: $BRANCH_NAME from tag: $(echo $OUTPUTS_NAME | tr -d '"')"
# Create branch from the tag
git fetch --tags
git checkout "$OUTPUTS_BRANCH"
git checkout "$(echo $OUTPUTS_BRANCH | tr -d '"')"
git checkout -b $BRANCH_NAME
# explicity set the github app token to override the release branch protection
git remote set-url origin "https://x-access-token:${OUTPUTS_TOKEN}@github.com/${{ env.RELEASE_REPO }}"
git remote set-url origin "https://x-access-token:$(echo ${OUTPUTS_TOKEN} | tr -d '"')@github.com/${{ env.RELEASE_REPO }}"
git push -u origin $BRANCH_NAME
echo "branch_exists=false" >> $GITHUB_OUTPUT
@ -272,7 +272,7 @@ jobs:
name: "download and prepare plugins"
run: |
echo "downloading images to $(pwd)/plugins"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/plugins .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/plugins .
mkdir -p "release/clients/cmd/docker-driver"
- name: "publish docker driver"
uses: "./lib/actions/push-images"
@ -313,7 +313,7 @@ jobs:
name: "download images"
run: |
echo "downloading images to $(pwd)/images"
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${SHA}/images .
gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/$(echo ${SHA} | tr -d '"')/images .
- name: "publish docker images"
uses: "./lib/actions/push-images"
with:
@ -370,7 +370,7 @@ jobs:
if: "${{ !fromJSON(needs.createRelease.outputs.exists) || (needs.createRelease.outputs.draft && fromJSON(needs.createRelease.outputs.draft)) }}"
name: "publish release"
run: |
gh release edit $OUTPUTS_NAME --draft=false --latest=$OUTPUTS_IS_LATEST
gh release edit $(echo $OUTPUTS_NAME | tr -d '"') --draft=false --latest=$(echo $OUTPUTS_IS_LATEST | tr -d '"')
working-directory: "release"
shouldRelease:
outputs:

Loading…
Cancel
Save