Repository navigation
ci(release): Release clients and server as Craft workspaces #737
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cc2000c
ci(release): Release clients and server as Craft workspaces
sentry-junior[bot] 5d3a648
ci(release): Never check out PR code in the changelog preview
sentry-junior[bot] 0cc369c
ci(release): Read PR paths from the API in the changelog preview
sentry-junior[bot] 6002762
ci(release): Drop the custom changelog preview and narrow server paths
sentry-junior[bot] b7679d9
ci(release): Tag server releases with a server@ prefix
sentry-junior[bot] e7513ce
ci(release): Add an empty server changelog
sentry-junior[bot] 3524bd1
ci(release): Preview changelogs per release workspace
sentry-junior[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| minVersion: 3.3.0 | ||
|
|
||
| # Each workspace is released on its own, with its own version, tags, release | ||
| # branch and changelog. Pick one with `--workspace <path>` or `CRAFT_WORKSPACE`. | ||
| # | ||
| # A workspace's changelog lists every PR that changes its directory or one of | ||
| # its `includePaths`. Files outside all workspaces (root config, CI, docs, ...) | ||
| # are excluded everywhere. Entries are grouped by the categories in | ||
| # `.github/release.yml`, which all workspaces share. | ||
| workspaces: | ||
| clients/python: | ||
| releaseBranchPrefix: release-py | ||
| preReleaseCommand: scripts/bump-version-py-client.sh | ||
| changelog: | ||
| policy: auto | ||
| scopeGrouping: false | ||
| unownedPaths: exclude | ||
| targets: | ||
| - name: github | ||
| tagPrefix: py-client@ | ||
| - name: pypi | ||
| - name: sentry-pypi | ||
| internalPypiRepo: getsentry/pypi | ||
| requireNames: | ||
| - /.*objectstore_client.*whl$/ | ||
| - /.*objectstore_client.*tar\.gz$/ | ||
|
|
||
| clients/rust: | ||
| releaseBranchPrefix: release-rust | ||
| preReleaseCommand: scripts/bump-version-rs-client.sh | ||
| changelog: | ||
| policy: auto | ||
| scopeGrouping: false | ||
| unownedPaths: exclude | ||
| # The crates target publishes from source, so there are no build artifacts. | ||
| artifactProvider: | ||
| name: none | ||
| targets: | ||
| - name: github | ||
| tagPrefix: rs-client@ | ||
| - name: crates | ||
|
|
||
| objectstore-server: | ||
| releaseBranchPrefix: release | ||
| preReleaseCommand: scripts/bump-version-server.sh | ||
| versioning: | ||
| policy: calver | ||
| changelog: | ||
| policy: auto | ||
| scopeGrouping: false | ||
| unownedPaths: exclude | ||
| # The crates the server binary is built from, plus its runtime options | ||
| # schema. Keep in sync with the server's path dependencies. | ||
| includePaths: | ||
| - objectstore-inventory-tracker | ||
| - objectstore-log | ||
| - objectstore-metrics | ||
| - objectstore-options | ||
| - objectstore-service | ||
| - objectstore-typed-options | ||
| - objectstore-typed-options-derive | ||
| - objectstore-types | ||
| - sentry-options | ||
| artifactProvider: | ||
| name: none | ||
| targets: | ||
| - name: github | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: Changelog Preview | ||
|
|
||
| # Comments on the PR with the changelogs it will be listed in, one per Craft | ||
| # workspace in `.craft.yml`, and the entry it adds to them. | ||
| # | ||
| # SECURITY: `pull_request_target` runs with a write token. Only the base | ||
| # branch is checked out. The PR's commits are fetched as git objects to read | ||
| # which files they change, but never checked out, so no PR file is read or run. | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened, edited, labeled, unlabeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: changelog-preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Craft | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| CRAFT_VERSION: 3.3.0 | ||
| run: | | ||
| gh release download "$CRAFT_VERSION" --repo getsentry/craft --pattern craft --dir "$RUNNER_TEMP" | ||
| sudo install "$RUNNER_TEMP/craft" /usr/local/bin/craft | ||
|
|
||
| - name: Comment changelog preview | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| CRAFT_LOG_LEVEL: Warn | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| BASE_REF: ${{ github.event.pull_request.base.ref }} | ||
| GIT_AUTHOR_NAME: changelog-preview | ||
| GIT_AUTHOR_EMAIL: changelog-preview@localhost | ||
| GIT_COMMITTER_NAME: changelog-preview | ||
| GIT_COMMITTER_EMAIL: changelog-preview@localhost | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Craft decides which workspaces a commit belongs to from the files it | ||
| # changes. Squash the PR into one commit on top of its merge base, like | ||
| # the merge will, and ask each workspace whether that commit is in it. | ||
| # `reset --soft` moves HEAD to that commit but keeps the base branch's | ||
| # files, so Craft reads its configuration from the base branch. | ||
| git fetch --quiet --no-tags origin "+refs/pull/$PR_NUMBER/head:refs/remotes/pr/head" | ||
| base=$(git merge-base pr/head "origin/$BASE_REF") | ||
| git reset --quiet --soft "$(git commit-tree "pr/head^{tree}" -p "$base" -m "#$PR_NUMBER")" | ||
|
|
||
| touched=() | ||
| impacts=() | ||
| entry="" | ||
| skipped=false | ||
| for workspace in $(craft workspace list | jq -r '.[]'); do | ||
| commits=$(CRAFT_WORKSPACE="$workspace" craft changelog --since "$base" --format json | jq '.totalCommits') | ||
| if [[ "$commits" == 0 ]]; then | ||
| continue | ||
| fi | ||
|
|
||
| result=$(CRAFT_WORKSPACE="$workspace" craft changelog --pr "$PR_NUMBER" --format json) | ||
| skipped=$(jq -r '.prSkipped' <<< "$result") | ||
| if [[ "$(jq -r '.versioningPolicy' <<< "$result")" == calver ]]; then | ||
| impact="CalVer" | ||
| else | ||
| case "$(jq -r '.bumpType' <<< "$result")" in | ||
| major) impact="🔴 Major" ;; | ||
| minor) impact="🟡 Minor" ;; | ||
| patch) impact="🟢 Patch" ;; | ||
| *) impact="⚪ None" ;; | ||
| esac | ||
| fi | ||
| touched+=("\`$workspace\`") | ||
| impacts+=("- \`$workspace\`: $impact") | ||
|
|
||
| # The entry is the same in every changelog. Craft quotes this PR's | ||
| # lines in the full preview; keep them and their section heading. | ||
| if [[ -z "$entry" ]]; then | ||
| entry=$(jq -r '.changelog' <<< "$result" | awk ' | ||
| /^#+ / { heading = $0; printed = 0; next } | ||
| /^>/ { | ||
| if (!printed && heading != "") { print heading "\n"; printed = 1 } | ||
| sub(/^> ?/, ""); print | ||
| }') | ||
| fi | ||
| done | ||
|
|
||
| marker="<!-- objectstore-changelog-preview -->" | ||
| if [[ ${#touched[@]} -eq 0 ]]; then | ||
| summary="This PR doesn't change any released workspace, so it won't be listed in any changelog." | ||
| elif [[ "$skipped" == true ]]; then | ||
| summary="This PR is excluded from the changelogs of the workspaces it changes (\`skip-changelog\`): ${touched[*]}" | ||
| else | ||
| summary="This PR will be listed in the changelogs of:"$'\n\n'"$(printf '%s\n' "${impacts[@]}")"$'\n\n'"$entry" | ||
| fi | ||
| body="$marker"$'\n'"## Changelog Preview"$'\n\n'"$summary" | ||
|
|
||
| comment_id=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ | ||
| --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) | ||
| if [[ -n "$comment_id" ]]; then | ||
| gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" -f body="$body" > /dev/null | ||
| elif [[ ${#touched[@]} -gt 0 ]]; then | ||
| gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -f body="$body" > /dev/null | ||
| fi | ||
| echo "$body" >> "$GITHUB_STEP_SUMMARY" | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
| set -euxo pipefail | ||
|
|
||
| ROOT_DIR="$(realpath $(dirname "$0")/..)" | ||
|
|
||
| OLD_VERSION="${1}" | ||
| NEW_VERSION="${2}" | ||
|
|
||
| echo "Current version: $OLD_VERSION" | ||
| echo "Bumping to version: $NEW_VERSION" | ||
|
|
||
| cd $ROOT_DIR | ||
| cd objectstore-server | ||
| perl -pi -e "s/^version = \".*?\"/version = \"$NEW_VERSION\"/" Cargo.toml | ||
|
|
||
| cd $ROOT_DIR | ||
| cargo metadata --format-version 1 >/dev/null # update `Cargo.lock` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.