start.sh 963 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # Set changeset status location
  4. # This is needed because `changeset status --output` only works with relative routes
  5. CHANGESETS_STATUS_JSON="$(realpath --relative-to=. "$RUNNER_TEMP/status.json")"
  6. # Save changeset status to temp file
  7. npx changeset status --output="$CHANGESETS_STATUS_JSON"
  8. # Defensive assertion. SHOULD NOT BE REACHED
  9. if [ "$(jq '.releases | length' "$CHANGESETS_STATUS_JSON")" != 1 ]; then
  10. echo "::error file=$CHANGESETS_STATUS_JSON::The status doesn't contain only 1 release"
  11. exit 1;
  12. fi;
  13. # Create branch
  14. BRANCH_SUFFIX="$(jq -r '.releases[0].newVersion | gsub("\\.\\d+$"; "")' $CHANGESETS_STATUS_JSON)"
  15. RELEASE_BRANCH="release-v$BRANCH_SUFFIX"
  16. git checkout -b "$RELEASE_BRANCH"
  17. # Output branch
  18. echo "branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT
  19. # Enter in prerelease state
  20. npx changeset pre enter rc
  21. git add .
  22. git commit -m "Start release candidate"
  23. # Push branch
  24. git push origin "$RELEASE_BRANCH"