Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/preview-release.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, the "base" workflow is caled publish - perhaps we should rename this one to match the base one more closely?

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release Branch

on:
workflow_dispatch:

permissions: {}

jobs:
release:
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how strong guarantees do we have here when it comes to what commit gets actually built and released? a workflow could get queued and also retried later - I feel this might be risky-ish because, I'd assume, it might run against the "current" version of a branch

a security researcher emailed me with a description of an atack like this:

  1. the maintainer schedules a job on a PR
  2. the attacker polls the github API against the triggering action (like a PR comment, or maybe a new workflow run)
  3. the attacker quickly pushes malicious stuff to that PR

It feels like this workflow would be prone to this attack. I know none of those preview builds can truly be trusted - but we should minimize the risks when we can.

- uses: ./.github/actions/ci-setup

- run: yarn changeset version --snapshot branch-${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: yarn build

- name: Setup Git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Release snapshot version
run: yarn run release:pr
env:
GITHUB_REF_NAME: ${{ github.ref_name }}

- name: Summarize preview release
run: |
commit_sha=$(git rev-parse HEAD)
repository_owner="${{ github.repository_owner }}"
repository_name="${{ github.event.repository.name }}"

{
echo "See the diff for this built version: https://github.com/changesets/action/compare/main...${repository_owner}:${repository_name}:${commit_sha}"
echo ""
echo "Use this preview build in a GitHub Actions workflow:"
echo ""
echo '```yaml'
echo " - uses: ${GITHUB_REPOSITORY}@${commit_sha}"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
183 changes: 0 additions & 183 deletions .github/workflows/release-pr.yml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/release-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "node:path";
import pkgJson from "../package.json" with { type: "json" };

const tag = `v${pkgJson.version}`;
const releaseLine = "pr-release";
const releaseLine = `built-${process.env.GITHUB_REF_NAME}`;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git stores branches as directories, perhaps we should use a pattern like this:

Suggested change
const releaseLine = `built-${process.env.GITHUB_REF_NAME}`;
const releaseLine = `built-pr/${process.env.GITHUB_REF_NAME}`;

this way they would be "grouped"


process.chdir(path.join(import.meta.dirname, ".."));

Expand Down