|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + ci: |
| 9 | + uses: ./.github/workflows/ci.yml |
| 10 | + cd: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - uses: actions/setup-node@v4 |
| 15 | + with: |
| 16 | + cache: 'npm' |
| 17 | + node-version-file: '.nvmrc' |
| 18 | + |
| 19 | + - name: Config GitHub user |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + git config --global user.name 'GitHub Actions' |
| 23 | + git config --global user.email 'github-actions@localhost' |
| 24 | +
|
| 25 | + - name: Update the version in the package files |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + GIT_TAG="${{github.event.release.tag_name}}" |
| 29 | + NEW_VERSION="${GIT_TAG/v/}" |
| 30 | +
|
| 31 | + bash ./scripts/update-dependencies-with-tag-versions.sh "$NEW_VERSION" |
| 32 | + git add package* && git commit -m "Release $NEW_VERSION" |
| 33 | +
|
| 34 | + - name: Install dependencies |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + - name: Build packages |
| 38 | + run: npm run build |
| 39 | + |
| 40 | + - name: Publish scratch-svg-renderer |
| 41 | + run: npm publish --access=public --workspace=@scratch/scratch-svg-renderer |
| 42 | + env: |
| 43 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 44 | + |
| 45 | + - name: Publish scratch-render |
| 46 | + run: npm publish --access=public --workspace=@scratch/scratch-render |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 49 | + |
| 50 | + - name: Publish scratch-vm |
| 51 | + run: npm publish --access=public --workspace=@scratch/scratch-vm |
| 52 | + env: |
| 53 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 54 | + |
| 55 | + - name: Publish scratch-gui |
| 56 | + run: npm publish --access=public --workspace=@scratch/scratch-gui |
| 57 | + env: |
| 58 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 59 | + |
| 60 | + - name: Push to develop |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + git fetch origin develop |
| 64 | +
|
| 65 | + TAG_NAME="${{github.event.release.tag_name}}" |
| 66 | + LAST_COMMIT_ID="$(git rev-parse $TAG_NAME)" |
| 67 | + DEVELOP_COMMIT_ID="$(git rev-parse origin/develop)" |
| 68 | +
|
| 69 | + if [ "$LAST_COMMIT_ID" = "$DEVELOP_COMMIT_ID" ]; then |
| 70 | + git push origin HEAD:develop |
| 71 | + else |
| 72 | + echo "Not pushing to develop because the tag we're operating on is behind" |
| 73 | + fi |
| 74 | +
|
| 75 | + # See https://stackoverflow.com/a/24849501 |
| 76 | + - name: Change connected commit on release |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + git tag -f "${{github.event.release.tag_name}}" HEAD |
| 80 | + git push -f origin "refs/tags/${{github.event.release.tag_name}}" |
| 81 | +
|
| 82 | + - name: Deploy scratch-svg-renderer to GitHub Pages |
| 83 | + uses: peaceiris/actions-gh-pages@v4 |
| 84 | + with: |
| 85 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + publish_dir: ./playground |
| 87 | + destination_dir: scratch-svg-renderer |
| 88 | + full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}" |
| 89 | + |
| 90 | + - name: Deploy scratch-render to GitHub Pages |
| 91 | + uses: peaceiris/actions-gh-pages@v4 |
| 92 | + with: |
| 93 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + publish_dir: ./playground |
| 95 | + destination_dir: scratch-render |
| 96 | + full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}" |
| 97 | + |
| 98 | + - name: Deploy scratch-vm to GitHub Pages |
| 99 | + uses: peaceiris/actions-gh-pages@v4 |
| 100 | + with: |
| 101 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + publish_dir: ./playground |
| 103 | + destination_dir: scratch-vm |
| 104 | + full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}" |
| 105 | + |
| 106 | + - name: Deploy scratch-gui to GitHub Pages |
| 107 | + uses: peaceiris/actions-gh-pages@v4 |
| 108 | + with: |
| 109 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + publish_dir: ./build |
| 111 | + destination_dir: scratch-gui |
| 112 | + full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}" |
| 113 | + needs: |
| 114 | + - ci |
0 commit comments