From d6bc889bb36ab8a1970da579f307abb8d0297170 Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 13:44:21 -0700 Subject: [PATCH 1/6] Update Github workflow --- .github/workflows/npmjs-publish.yml | 44 --------------------------- .github/workflows/prepare-release.yml | 37 ++++++++++++++++++++++ .github/workflows/publish.yml | 36 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/npmjs-publish.yml create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/npmjs-publish.yml b/.github/workflows/npmjs-publish.yml deleted file mode 100644 index 23c6748d..00000000 --- a/.github/workflows/npmjs-publish.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build and Upload Package - -on: - release: - types: [published] - workflow_dispatch: - inputs: - version: - description: 'What version to use for the release' - required: true - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Set release version - run: | - tag="${{ github.event.inputs.version }}" - if [ -z "$tag" ]; then - tag="${GITHUB_REF_NAME}" - fi - version="${tag#v}" # Strip leading v - - # Bump library tag - npm version --no-git-tag-version "$version" - - git config user.name 'GitHub Actions' - git config user.email eng+github@repl.it - - git commit -m 'Setting version' package.json - - - name: Build and publish - run: | - npm set "//registry.npmjs.org/:_authToken" "${{ secrets.NPMJS_AUTH_TOKEN }}" - npm install --frozen-lockfile - npm run release diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000..0217ed80 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,37 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + bump: + description: 'Version bump type (major, minor, or patch)' + required: true + type: choice + options: + - major + - minor + - patch + +jobs: + tag-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Configure Git + run: | + git config user.name 'GitHub Actions' + git config user.email eng+github@repl.it + + - name: Bump version and create tag + run: | + # This command updates package.json, creates a commit, and adds a tag + npm version ${{ github.event.inputs.bump }} + + - name: Push changes and tags + run: git push --follow-tags diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..85b04e9c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +# .github/workflows/publish.yml +name: Build and Publish Package + +on: + push: + tags: + - 'v*' # Trigger on tags like v1.0.0, v2.3.4, etc. + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout code + # This checks out the code at the specific tag that triggered the workflow + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org/' + + - name: Install dependencies and build + run: npm ci + + - name: Publish to npm + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }} + + - name: Publish GitHub Release + uses: release-drafter/release-drafter@v5 + with: + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From dcb2774c4f0489c4effe219b0c3bc97144fac7f5 Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 14:07:11 -0700 Subject: [PATCH 2/6] Update README and workflow for automated release --- .github/workflows/prepare-release.yml | 42 ++++++++++++++++++--------- README.md | 38 ++++++++++-------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 0217ed80..48d40769 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -2,22 +2,30 @@ name: Prepare Release on: workflow_dispatch: - inputs: - bump: - description: 'Version bump type (major, minor, or patch)' - required: true - type: choice - options: - - major - - minor - - patch jobs: tag-release: runs-on: ubuntu-latest + permissions: + # We need contents: read to checkout the repo and read PRs/tags. + # We need contents: write to push the new version commit and tag. + contents: write + pull-requests: read + steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Run release-drafter to determine the next version + - name: Determine next version from release-drafter + id: release_drafter + uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Use the output from the previous step to version the package - name: Setup Node uses: actions/setup-node@v4 with: @@ -26,12 +34,20 @@ jobs: - name: Configure Git run: | git config user.name 'GitHub Actions' - git config user.email eng+github@repl.it + git config user.email 'eng+github@repl.it' - name: Bump version and create tag run: | - # This command updates package.json, creates a commit, and adds a tag - npm version ${{ github.event.inputs.bump }} + # Get the tag_name output from the release-drafter step + tag="${{ steps.release_drafter.outputs.tag_name }}" + + # Strip the 'v' prefix to get the bare version number + version="${tag#v}" + + echo "Next version calculated by release-drafter is: $version" + + # Use the calculated version with npm version + npm version "$version" - name: Push changes and tags run: git push --follow-tags diff --git a/README.md b/README.md index c85f0aea..5bd57534 100644 --- a/README.md +++ b/README.md @@ -280,29 +280,21 @@ River uses an automated release process with [Release Drafter](https://github.co ### Automated Release Process (Recommended) -1. **Label your PRs** with the appropriate version bump: - +1. **Merge PRs to main** - Release Drafter automatically: + - Updates the draft release notes with PR titles + - You can view the draft at [GitHub Releases](../../releases) + +2. **When ready to release**: + - Go to [Actions](../../actions/workflows/prepare-release.yml) + - Click "Run workflow" + - Click "Run workflow" (version is automatically determined from draft release) + + The version bump is automatically calculated based on PR labels: - `patch` - Bug fixes, small improvements (e.g., 0.208.4 → 0.208.5) - - `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0) + - `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0) - `major` - Breaking changes (e.g., 0.208.4 → 1.0.0) -2. **Merge PRs to main** - Release Drafter automatically: - - - Creates/updates a draft release with the calculated version - - Generates release notes from PR titles - - Determines version bump based on the highest label used - -3. **Publish the release** when ready: - - Go to [GitHub Releases](../../releases) - - Review the draft release notes - - Click "Publish release" - - This automatically publishes to NPM - -### Manual Release (Alternative) - -For hotfixes or special cases, you can manually trigger a release: - -1. Go to [Actions](../../actions/workflows/npmjs-publish.yml) -2. Click "Run workflow" -3. Enter the desired version (e.g., `0.208.5`) -4. Click "Run workflow" +3. **Automation takes over**: + - The "Prepare Release" workflow bumps the version and creates a git tag + - The git tag automatically triggers the "Build and Publish" workflow + - The `river` package is published to NPM and the GitHub release is created From f661650f430812ae3b4d6b00e452b2877041e164 Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 14:08:18 -0700 Subject: [PATCH 3/6] ... --- .github/workflows/prepare-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 48d40769..f3b29f84 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -7,8 +7,6 @@ jobs: tag-release: runs-on: ubuntu-latest permissions: - # We need contents: read to checkout the repo and read PRs/tags. - # We need contents: write to push the new version commit and tag. contents: write pull-requests: read From 415d72f6c63d9714c355df0c4d0eb74e5cd6748c Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 14:09:14 -0700 Subject: [PATCH 4/6] Update README.md Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bd57534..fed02487 100644 --- a/README.md +++ b/README.md @@ -286,8 +286,8 @@ River uses an automated release process with [Release Drafter](https://github.co 2. **When ready to release**: - Go to [Actions](../../actions/workflows/prepare-release.yml) - - Click "Run workflow" - - Click "Run workflow" (version is automatically determined from draft release) + - Click "Run workflow" to open the configuration dialog + - Click "Run workflow" again to confirm and start the process (version is automatically determined from draft release) The version bump is automatically calculated based on PR labels: - `patch` - Bug fixes, small improvements (e.g., 0.208.4 → 0.208.5) From 438cd69daef21fe9684361f9ee3a00b6392de00a Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 14:11:27 -0700 Subject: [PATCH 5/6] format --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fed02487..b1cbad24 100644 --- a/README.md +++ b/README.md @@ -281,17 +281,20 @@ River uses an automated release process with [Release Drafter](https://github.co ### Automated Release Process (Recommended) 1. **Merge PRs to main** - Release Drafter automatically: + - Updates the draft release notes with PR titles - You can view the draft at [GitHub Releases](../../releases) 2. **When ready to release**: - - Go to [Actions](../../actions/workflows/prepare-release.yml) + + - Go to [Actions](../../actions/workflows/prepare-release.yml) - Click "Run workflow" to open the configuration dialog - Click "Run workflow" again to confirm and start the process (version is automatically determined from draft release) - + The version bump is automatically calculated based on PR labels: + - `patch` - Bug fixes, small improvements (e.g., 0.208.4 → 0.208.5) - - `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0) + - `minor` - New features, backwards compatible (e.g., 0.208.4 → 0.209.0) - `major` - Breaking changes (e.g., 0.208.4 → 1.0.0) 3. **Automation takes over**: From 887cdd6f027d2251c0f7b9c808127546658a684a Mon Sep 17 00:00:00 2001 From: Dawei Date: Mon, 16 Jun 2025 14:27:54 -0700 Subject: [PATCH 6/6] Use node 22 in ci --- .github/workflows/ci.yaml | 8 ++++---- .github/workflows/prepare-release.yml | 2 +- .github/workflows/publish.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 272b2140..d9e328a8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,17 +20,17 @@ jobs: actions: read checks: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index f3b29f84..1ba563b5 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 - name: Configure Git run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 85b04e9c..3f779ff3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 registry-url: 'https://registry.npmjs.org/' - name: Install dependencies and build