diff options
-rw-r--r-- | .github/workflows/preview-comment.yml | 26 | ||||
-rw-r--r-- | .github/workflows/preview-release.yml | 21 | ||||
-rw-r--r-- | .github/workflows/snapshot-release.yml | 206 | ||||
-rw-r--r-- | CONTRIBUTING.md | 6 |
4 files changed, 6 insertions, 253 deletions
diff --git a/.github/workflows/preview-comment.yml b/.github/workflows/preview-comment.yml deleted file mode 100644 index 9fb0f48c3..000000000 --- a/.github/workflows/preview-comment.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Add continuous release label - -on: - issue_comment: - types: [created] - -permissions: - pull-requests: write - -jobs: - label: - if: ${{ github.repository_owner == 'withastro' && startsWith(github.event.comment.body, '!preview') }} - runs-on: ubuntu-latest - - steps: - - name: Check if user has write access - uses: lannonbr/repo-permission-check-action@2.0.2 - with: - permission: write - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - run: | - gh issue edit ${{ github.event.issue.number }} --add-label "pr: preview" --repo ${{ github.repository }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 40a730af1..0b8394dca 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -55,27 +55,6 @@ jobs: - name: Build Packages run: pnpm run build -# - name: Changesets status -# run: pnpm changeset status --output=changesets.json -# -# - name: Retrieve packages to publish -# uses: actions/github-script@v7 -# id: packages -# with: -# script: | -# const fs = require('fs'); -# let packages = JSON.parse(fs.readFileSync('changesets.json', 'utf8')); -# const releases = packages.releases -# .filter(p => { -# return p.changesets.length > 0; -# }) -# .map(p => p.name); -# if (releases.length > 0) { -# return releases.join(' '); -# } -# return "" -# result-encoding: string - - name: Publish packages run: | pnpm dlx pkg-pr-new publish --pnpm --compact --no-template 'packages/astro' 'packages/integrations/node' 'packages/integrations/cloudflare' 'packages/integrations/netlify' 'packages/integrations/vercel' diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml deleted file mode 100644 index 483e72e0f..000000000 --- a/.github/workflows/snapshot-release.yml +++ /dev/null @@ -1,206 +0,0 @@ -name: Create a Snapshot Release - -on: - workflow_dispatch: - issue_comment: - types: [created] - -defaults: - run: - shell: bash - -env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} - FORCE_COLOR: 1 - -jobs: - snapshot-release: - name: Create a snapshot release of a pull request - if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && (contains(github.event.comment.body, '!preview') || contains(github.event.comment.body, '/preview') || contains(github.event.comment.body, '!snapshot') || contains(github.event.comment.body, '/snapshot')) }} - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - issues: write - pull-requests: write - steps: - - name: Check if user has write access - uses: lannonbr/repo-permission-check-action@2.0.2 - with: - permission: write - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract the snapshot name from comment body - id: getSnapshotName - uses: actions/github-script@v7 - with: - script: | - const { body } = context.payload.comment; - const PREVIEW_RE = /^[!\/](?:preview|snapshot)\s+(\S*)\s*$/gim; - const [_, name] = PREVIEW_RE.exec(body) ?? []; - if (name) return name; - - const error = 'Invalid command. Expected: "/preview <snapshot-name>"' - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: error, - }) - core.setFailed(error) - result-encoding: string - - - name: resolve pr refs - id: refs - uses: eficode/resolve-pr-refs@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions/checkout@v4 - with: - ref: ${{ steps.refs.outputs.head_ref }} - fetch-depth: 0 - - - name: Extract base branch from .changeset/config.json - id: getBaseBranch - run: | - baseBranch=$(jq -r '.baseBranch' .changeset/config.json) - echo "baseBranch=${baseBranch}" >> $GITHUB_OUTPUT - - - run: git fetch origin ${{ steps.getBaseBranch.outputs.baseBranch }}:${{ steps.getBaseBranch.outputs.baseBranch }} - - - name: Setup PNPM - uses: pnpm/action-setup@v3 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 22 - registry-url: "https://registry.npmjs.org" - cache: "pnpm" - - - name: Install dependencies - run: pnpm install - - - name: Build Packages - run: pnpm run build - - - name: Bump Package Versions - id: changesets - run: | - pnpm exec changeset status --output status.output.json 2>&1 - # Snapshots don't work in pre mode. See https://github.com/changesets/changesets/issues/1195 - pnpm exec changeset pre exit || true - pnpm exec changeset version --snapshot ${{ steps.getSnapshotName.outputs.result }} - - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "status<<$EOF" >> $GITHUB_OUTPUT - echo "$(cat status.output.json)" >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - env: - # Needs access to run the script - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Disable color - FORCE_COLOR: 0 - NO_COLOR: 1 - - - name: Publish Release - id: publish - run: | - set -o pipefail - GITHUB_ACTIONS=0 pnpm run build 2>&1 | tee build.output.txt - BUILD_EXIT_CODE=$? - - if [ $BUILD_EXIT_CODE -ne 0 ]; then - echo "::error::Build failed. See output above." - # Store the build output for the notification step before exiting - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "build<<$EOF" >> $GITHUB_OUTPUT - echo "$(cat build.output.txt)" >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - exit 1 - fi - - pnpm exec changeset publish --tag experimental--${{ steps.getSnapshotName.outputs.result }} 2>&1 | tee publish.output.txt - PUBLISH_EXIT_CODE=$? - - if [ $PUBLISH_EXIT_CODE -ne 0 ]; then - echo "::error::Publish failed. See output above." - fi - - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - - echo "build<<$EOF" >> $GITHUB_OUTPUT - echo "$(cat build.output.txt)" >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - - echo "publish<<$EOF" >> $GITHUB_OUTPUT - echo "$(cat publish.output.txt)" >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - - # Exit with error if publish failed - exit $PUBLISH_EXIT_CODE - env: - # Needs access to publish to npm - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Disable color - FORCE_COLOR: 0 - NO_COLOR: 1 - - - name: Pull Request Notification - uses: actions/github-script@v7 - if: always() - env: - TAG: ${{ steps.getSnapshotName.outputs.result }} - STATUS_DATA: ${{ steps.changesets.outputs.status }} - BUILD_LOG: ${{ steps.publish.outputs.build }} - PUBLISH_LOG: ${{ steps.publish.outputs.publish }} - JOB_STATUS: ${{ job.status }} - with: - script: | - let changeset = { releases: [] }; - try { - changeset = JSON.parse(process.env.STATUS_DATA); - } catch (e) {} - - let message = ''; - - if (process.env.JOB_STATUS === 'success') { - message = 'Snapshots have been released for the following packages:'; - for (const release of changeset.releases) { - if (release.type === 'none') continue; - message += `\n- \`${release.name}@experimental--${process.env.TAG}\``; - } - } else { - message = '❌ Snapshot release failed.'; - } - - function details(title, body, failed = false) { - if (!body) return; - message += '\n'; - const icon = failed ? '❌ ' : ''; - message += `<details><summary><strong>${icon}${title}</strong></summary>`; - message += '\n\n```\n'; - message += body; - message += '\n```\n\n</details>'; - } - - // Show build log first if it exists - if (process.env.BUILD_LOG) { - details('Build Log', process.env.BUILD_LOG, process.env.JOB_STATUS !== 'success'); - } - - // Only show publish log if it exists (might not if build failed) - if (process.env.PUBLISH_LOG) { - details('Publish Log', process.env.PUBLISH_LOG, process.env.JOB_STATUS !== 'success'); - } - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: message, - }) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d44be03b8..bc358818f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -283,6 +283,12 @@ Assigning labels isn't always easy and many times the distinction between the di - In case the number of reactions of an issue grows, the number of users affected grows, or a discussion uncovers some insights that weren't clear before, it's OK to change the priority of the issue. The maintainer **should** provide an explanation when assigning a different label. As with any other contribution, triaging is voluntary and best-efforts. We welcome and appreciate all the help you're happy to give (including reading this!) and nothing more. If you are not confident about an issue, you are welcome to leave an issue untriaged for someone who would have more context, or to bring it to their attention. +### Preview releases + +You can trigger a preview release **from a PR** anytime by using the label `pr: preview`. Add this label, and a workflow will trigger, which at the end will add a comment with the instructions of how to install the preview release. + +If you're in need to trigger multiple preview releases from the same PR, remove the label and add it again. + ## Code Structure Server-side rendering (SSR) can be complicated. The Astro package (`packages/astro`) is structured in a way to help think about the different systems. |