-
Notifications
You must be signed in to change notification settings - Fork 161
Publish tested builds #478
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
cwillisf
wants to merge
5
commits into
develop
Choose a base branch
from
publish-tested-builds
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+175
−68
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
05c7c7a
ci: general GHA cleanup
cwillisf 37a61b3
ci: publish the builds that were tested
cwillisf dac1ab6
ci(publish): add release comments on issues & PRs
cwillisf 3ec8e87
ci: handle empty test matrix better
cwillisf 9c4f407
build: don't build on prepublish & enforce publish through CI
cwillisf 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,42 +5,105 @@ on: | |
| types: [published] | ||
|
|
||
| jobs: | ||
| ci: | ||
| find-artifacts: | ||
| name: Find CI artifacts | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| ci-run-id: ${{ steps.find.outputs.run-id }} | ||
| needs-build: ${{ steps.find.outputs.needs-build }} | ||
| steps: | ||
| - name: Find successful CI run for release target | ||
| id: find | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| TARGET: ${{ github.event.release.target_commitish }} | ||
| shell: bash | ||
| run: | | ||
| # Resolve branch name or tag to a commit SHA | ||
| SHA=$(gh api "repos/$GITHUB_REPOSITORY/commits/$TARGET" --jq '.sha' 2>/dev/null || echo "$TARGET") | ||
| echo "Resolved target '$TARGET' to SHA: $SHA" | ||
|
|
||
| # Find the most recent successful CI run for this SHA | ||
| RUN_ID=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs" \ | ||
| -F "head_sha=$SHA" \ | ||
| -F "status=success" \ | ||
cwillisf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -F "per_page=1" \ | ||
| --jq '.workflow_runs[0].id // empty') || { | ||
| echo "::error::Failed to query CI workflow runs. If ci.yml was renamed, update the reference in the find-artifacts job in publish.yml." | ||
| exit 1 | ||
| } | ||
|
|
||
| if [ -z "$RUN_ID" ]; then | ||
| echo "No successful CI run found for SHA $SHA. A fresh build will be triggered." | ||
| echo "run-id=" >> "$GITHUB_OUTPUT" | ||
| echo "needs-build=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "Found successful CI run: $RUN_ID" | ||
| echo "run-id=$RUN_ID" >> "$GITHUB_OUTPUT" | ||
| echo "needs-build=false" >> "$GITHUB_OUTPUT" | ||
cwillisf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| build: | ||
| name: Build (no prior CI run found) | ||
| needs: find-artifacts | ||
| if: ${{ needs.find-artifacts.outputs.needs-build == 'true' }} | ||
| uses: ./.github/workflows/ci.yml | ||
| with: | ||
| force-full-build: true | ||
|
|
||
| cd: | ||
| name: Publish to npm | ||
| needs: | ||
| - ci | ||
| - find-artifacts | ||
| - build | ||
| # Run if find-artifacts succeeded AND (build succeeded OR build was skipped because artifacts already exist) | ||
| if: ${{ !cancelled() && needs.find-artifacts.result == 'success' && (needs.build.result == 'success' || needs.build.result == 'skipped') }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read # to download artifacts from the CI run | ||
| contents: write # to push the version commit and tag | ||
| issues: write # to comment on issues when a fix is released | ||
| pull-requests: write # to comment on PRs when a fix is released | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| steps: | ||
| - name: Debug info | ||
| # https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable | ||
| env: | ||
| # `env:` values are printed to the log even without using them in `run:` | ||
| RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} | ||
| RELEASE_TARGET_COMMITISH: ${{ github.event.release.target_commitish }} | ||
| run: | | ||
| cat <<EOF | ||
| Release tag name: ${{ github.event.release.tag_name }} | ||
| Release target commit-ish: ${{ github.event.release.target_commitish }} | ||
| Release tag name: $RELEASE_TAG_NAME | ||
| Release target commit-ish: $RELEASE_TARGET_COMMITISH | ||
| EOF | ||
|
|
||
| - name: Determine NPM tag | ||
| id: npm_tag | ||
| shell: bash | ||
| env: | ||
| TARGET_COMMITISH: ${{ github.event.release.target_commitish }} | ||
| IS_PRERELEASE: ${{ github.event.release.prerelease }} | ||
| run: | | ||
| case ${{ github.event.release.target_commitish }} in | ||
| case "$TARGET_COMMITISH" in | ||
| develop | main | master) | ||
| if [[ ${{ github.event.release.prerelease }} == true ]]; then | ||
| if [[ "$IS_PRERELEASE" == true ]]; then | ||
| npm_tag=beta | ||
| else | ||
| npm_tag=latest | ||
| fi | ||
| ;; | ||
| *) | ||
| # use the branch name | ||
| npm_tag="${{ github.event.release.target_commitish }}" | ||
| # use the branch name as the npm tag | ||
| npm_tag="$TARGET_COMMITISH" | ||
| ;; | ||
| esac | ||
| echo "Determined NPM tag: [$npm_tag]" | ||
| echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT" | ||
| echo "NPM_TAG=${npm_tag}" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Check NPM tag | ||
| run: | | ||
| if [ -z "${{ steps.npm_tag.outputs.npm_tag }}" ]; then | ||
| if [ -z "$NPM_TAG" ]; then | ||
| echo "Refusing to publish with empty NPM tag." | ||
| exit 1 | ||
| fi | ||
|
|
@@ -63,76 +126,67 @@ jobs: | |
|
|
||
| - uses: ./.github/actions/install-dependencies | ||
|
|
||
| - name: Download build artifacts (from previous CI run) | ||
| if: ${{ needs.build.result == 'skipped' }} | ||
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6 | ||
| with: | ||
| name: build | ||
| path: packages | ||
| run-id: ${{ needs.find-artifacts.outputs.ci-run-id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Download build artifacts (from fallback build in this run) | ||
| if: ${{ needs.build.result == 'success' }} | ||
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6 | ||
| with: | ||
| name: build | ||
| path: packages | ||
|
|
||
| - name: Update the version in the package files | ||
| shell: bash | ||
| env: | ||
| GIT_TAG: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| GIT_TAG="${{github.event.release.tag_name}}" | ||
| NEW_VERSION="${GIT_TAG/v/}" | ||
|
|
||
| npm version "$NEW_VERSION" --no-git-tag-version | ||
| git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci]" | ||
|
|
||
| # Install dependencies after the version update so that | ||
| # the build outputs refer to the newest version of inner packages | ||
| - uses: ./.github/actions/install-dependencies | ||
|
|
||
| - name: Publish scratch-svg-renderer | ||
| run: | | ||
| npm run build --workspace @scratch/scratch-svg-renderer | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-svg-renderer | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
| run: npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/scratch-svg-renderer | ||
|
|
||
| - name: Publish scratch-render | ||
| run: | | ||
| npm run build --workspace @scratch/scratch-render | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-render | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
| run: npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/scratch-render | ||
|
|
||
| - name: Publish scratch-vm | ||
| run: | | ||
| npm run build --workspace @scratch/scratch-vm | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-vm | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
| run: npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/scratch-vm | ||
|
|
||
cwillisf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Publish scratch-gui | ||
| run: | | ||
| cp ./packages/scratch-gui/package.json ./packages/scratch-gui/package-copy.json | ||
|
|
||
| jq 'del(.exports["./standalone"])' ./packages/scratch-gui/package.json | npx sponge ./packages/scratch-gui/package.json | ||
|
|
||
| npm run build:dist --workspace @scratch/scratch-gui | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui | ||
| npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/scratch-gui | ||
|
|
||
| mv ./packages/scratch-gui/package-copy.json ./packages/scratch-gui/package.json | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
|
|
||
| - name: Publish scratch-gui-standalone | ||
| run: | | ||
| bash ./scripts/prepare-standalone-gui.sh | ||
|
|
||
| npm --workspace=@scratch/scratch-gui-standalone run clean && npm --workspace=@scratch/scratch-gui-standalone run build:dist-standalone | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui-standalone | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
| npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/scratch-gui-standalone | ||
|
|
||
| - name: Publish task-herder | ||
| run: | | ||
| npm run build --workspace @scratch/task-herder | ||
| npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/task-herder | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
| run: npm publish --access=public --tag="$NPM_TAG" --workspace=@scratch/task-herder | ||
|
|
||
| - name: Push to develop | ||
| shell: bash | ||
| env: | ||
| TAG_NAME: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| git fetch origin develop | ||
|
|
||
| TAG_NAME="${{github.event.release.tag_name}}" | ||
| LAST_COMMIT_ID="$(git rev-parse $TAG_NAME)" | ||
| LAST_COMMIT_ID="$(git rev-parse "$TAG_NAME")" | ||
| DEVELOP_COMMIT_ID="$(git rev-parse origin/develop)" | ||
|
|
||
| if [ "$LAST_COMMIT_ID" = "$DEVELOP_COMMIT_ID" ]; then | ||
|
|
@@ -141,9 +195,19 @@ jobs: | |
| echo "Not pushing to develop because the tag we're operating on is behind" | ||
| fi | ||
|
|
||
| - name: Comment on resolved issues and merged PRs | ||
|
Contributor
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. Cool! |
||
| if: ${{ !github.event.release.prerelease }} | ||
| uses: apexskier/github-release-commenter@e7813a9625eabd79a875b4bc4046cfcae377ab34 # v1 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| comment-template: | | ||
| :tada: This is included in release {release_link}. | ||
|
|
||
| # See https://stackoverflow.com/a/24849501 | ||
| - name: Change connected commit on release | ||
| shell: bash | ||
| env: | ||
| TAG_NAME: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| git tag -f "${{github.event.release.tag_name}}" HEAD | ||
| git push -f origin "refs/tags/${{github.event.release.tag_name}}" | ||
| git tag -f "$TAG_NAME" HEAD | ||
| git push -f origin "refs/tags/$TAG_NAME" | ||
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.