-
Notifications
You must be signed in to change notification settings - Fork 11
Adds release script to do the minor or patch release #301
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
base: main
Are you sure you want to change the base?
Changes from all commits
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,77 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
| MCP_IMAGE_NAME: ${{ github.repository }}-mcp-server | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Create Draft Release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate tag format | ||
| run: | | ||
| TAG="${{ github.ref_name }}" | ||
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::Invalid tag format: ${TAG}. Expected vMAJOR.MINOR.PATCH (e.g., v0.12.0)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
Comment on lines
+29
to
+32
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. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
wc -l .github/workflows/release.yml
cat -n .github/workflows/release.yml | sed -n '1,220p'Repository: redhat-data-and-ai/unstructured-data-controller Length of output: 3223 Guard release tags before running Any push to 🧰 Tools🪛 zizmor (1.26.1)[warning] 29-32: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Determine release type | ||
| id: info | ||
| run: | | ||
| TAG="${{ github.ref_name }}" | ||
| PATCH_NUM="${TAG##*.}" | ||
| MINOR_VERSION="${TAG%.*}" | ||
| if [[ "$PATCH_NUM" == "0" ]]; then | ||
| echo "type=minor" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "type=patch" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| echo "minor_version=${MINOR_VERSION}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run release script (minor) | ||
| if: steps.info.outputs.type == 'minor' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| chmod +x hack/release.sh | ||
| hack/release.sh minor --version "${{ github.ref_name }}" --force | ||
|
|
||
| - name: Run release script (patch) | ||
| if: steps.info.outputs.type == 'patch' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| chmod +x hack/release.sh | ||
| hack/release.sh patch "${{ steps.info.outputs.minor_version }}" --version "${{ github.ref_name }}" --force | ||
|
|
||
| - name: Summary | ||
| run: | | ||
| TAG="${{ github.ref_name }}" | ||
| { | ||
| echo "## Draft Release ${TAG}" | ||
| echo "" | ||
| echo "- **Release**: https://github.com/${{ github.repository }}/releases/tag/${TAG}" | ||
| echo "- **Controller image**: \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG}\`" | ||
| echo "- **MCP server image**: \`${{ env.REGISTRY }}/${{ env.MCP_IMAGE_NAME }}:${TAG}\`" | ||
| if [[ "${{ steps.info.outputs.type }}" == "minor" ]]; then | ||
| echo "- **Release branch**: \`release-${{ steps.info.outputs.minor_version }}.x\`" | ||
| fi | ||
| echo "" | ||
| echo "> **Note:** This is a draft release. Review the release notes and publish when ready." | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Unsanitized
${{ github.ref_name }}/context values interpolated directly intorun:scripts (template injection).Lines 23, 37, 54, 66, 71-73 splice GitHub context expressions (
github.ref_name,steps.info.outputs.*,github.repository) directly into shell script text rather than passing them throughenv:. Notably, the very step meant to validate the tag (line 21-27) itself performs this interpolation before any validation occurs, so a maliciously-crafted tag name (by anyone with tag-push access) could inject shell syntax before the format check ever runs. The standard mitigation is to pass these values viaenv:and reference them as"$VAR"inside the script, which makes the value pure data instead of script text.🔒 Proposed fix (pattern to apply at each flagged step)
Apply the same
env:-passing pattern to the "Determine release type" and "Summary" steps forgithub.ref_name,steps.info.outputs.type, andsteps.info.outputs.minor.📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.26.1)
[error] 23-23: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
🤖 Prompt for AI Agents
Source: Linters/SAST tools