Repository navigation
feat(api): Move the @sentry/api package into static/packages/api #130472
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
Open
+25,707
−20
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6fef5d3
feat(api): Move the @sentry/api package into static/packages/api
sentry-junior[bot] 185cc83
:hammer_and_wrench: apply pre-commit fixes
getsantry[bot] f1d63ca
fix(api): Address CodeQL alerts in the moved @sentry/api sources
sentry-junior[bot] 005a1fd
chore(api): Make owners-api the code owner of static/packages/api
sentry-junior[bot] d835eb1
feat(api): Attach the spec files to api@ GitHub releases instead of npm
sentry-junior[bot] 74efdbf
fix(api): Fail the release preflight when the last release has no spe…
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
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
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 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 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
104 changes: 104 additions & 0 deletions
104
.github/workflows/scripts/api-package-release-preflight.sh
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,104 @@ | ||
| #!/bin/sh | ||
| # Decides whether openapi.yml releases @sentry/api from HEAD, a master commit | ||
| # whose spec files are in SPEC_DIR. To release, writes the version bump for | ||
| # craft to $GITHUB_OUTPUT as version=<bump>. To skip, writes nothing. | ||
| # | ||
| # The release-branch and tag checks follow getsentry/sentry-api-schema#137's | ||
| # release-preflight.sh, so a burst of merges releases once and nothing that | ||
| # lands while a release is pending is left unreleased. | ||
| # | ||
| # Environment: | ||
| # SPEC_DIR The package's spec/ files built from HEAD. | ||
| # GH_TOKEN A token that can read this repository's releases. | ||
| # GITHUB_REPOSITORY Set by GitHub Actions. | ||
| # GITHUB_OUTPUT Set by GitHub Actions. | ||
| set -eu | ||
|
|
||
| package_dir=static/packages/api | ||
| tag_prefix=api@ | ||
|
|
||
| skip() { | ||
| printf '::notice::%s\n' "$1" | ||
| exit 0 | ||
| } | ||
|
|
||
| if [ ! -f "$SPEC_DIR/openapi-derefed.json" ]; then | ||
| printf '::error::%s has no openapi-derefed.json.\n' "$SPEC_DIR" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Automatic releases start after a person cuts the first one from here. | ||
| if ! base=$(git describe --tags --abbrev=0 --match "$tag_prefix*" 2>/dev/null); then | ||
| skip "No $tag_prefix release yet. Cut the first one with the Release workflow." | ||
| fi | ||
|
|
||
| # Craft refuses to cut a release while one is pending. When that release | ||
| # merges into master, the run for the merge releases whatever landed meanwhile. | ||
| pending=$(git ls-remote --heads origin "refs/heads/${tag_prefix%@}/release/*") | ||
| if [ -n "$pending" ]; then | ||
| skip "A release is still pending: $pending" | ||
| fi | ||
|
|
||
| # Craft takes the next version from the latest tag in HEAD's history. A newer | ||
| # tag outside it means HEAD predates that release, and the run for that | ||
| # release's merge covers this commit. | ||
| tags=$(git tag --list "$tag_prefix*" --sort=-version:refname) | ||
| newest=${tags%%[[:space:]]*} | ||
| if [ "$newest" != "$base" ]; then | ||
| skip "HEAD predates release $newest." | ||
| fi | ||
|
|
||
| released=$(mktemp -d) | ||
| trap 'rm -rf "$released"' EXIT | ||
| trap 'exit 1' INT TERM | ||
| # The last release's GitHub release has the spec files it was built from as | ||
| # assets. Craft's github target attaches them before craft merges the release | ||
| # branch, so a run for that merge sees them. A release without them cannot be | ||
| # compared, and treating every file as changed would cut a release for nothing. | ||
| json_assets=$(timeout 60 gh release view "$base" --repo "$GITHUB_REPOSITORY" \ | ||
| --json assets --jq '[.assets[].name | select(endswith(".json"))] | length') | ||
| if [ "$json_assets" -eq 0 ]; then | ||
| printf '::error::Release %s has no spec files attached to compare with.\n' "$base" | ||
| exit 1 | ||
| fi | ||
| timeout 300 gh release download "$base" --repo "$GITHUB_REPOSITORY" \ | ||
| --pattern '*.json' --dir "$released" | ||
|
|
||
| spec_changed=false | ||
| data_changed=false | ||
| for file in "$SPEC_DIR"/*; do | ||
| name=${file##*/} | ||
| # cmp exits 1 when the files differ and 2 when the release lacks the file. | ||
| if ! cmp -s "$file" "$released/$name"; then | ||
| if [ "$name" = openapi-derefed.json ]; then | ||
| spec_changed=true | ||
| else | ||
| data_changed=true | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| if git diff --quiet "$base" HEAD -- "$package_dir"; then | ||
| package_changed=false | ||
| else | ||
| status=$? | ||
| if [ "$status" -ne 1 ]; then | ||
| exit "$status" | ||
| fi | ||
| package_changed=true | ||
| fi | ||
|
|
||
| # Spec updates are minor releases, as they were in sentry-api-schema. Package | ||
| # changes take craft's bump from their commits. Ownership or RPC schema | ||
| # changes alone are patches. | ||
| if [ "$spec_changed" = true ]; then | ||
| bump='minor' | ||
| elif [ "$package_changed" = true ]; then | ||
| bump='auto' | ||
| elif [ "$data_changed" = true ]; then | ||
| bump='patch' | ||
| else | ||
| skip "Nothing changed since $base." | ||
| fi | ||
| printf '::notice::Releasing a %s bump on %s.\n' "$bump" "$base" | ||
| printf 'version=%s\n' "$bump" >>"$GITHUB_OUTPUT" | ||
Oops, something went wrong.
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.