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/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..1ba563b5 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,51 @@ +name: Prepare Release + +on: + workflow_dispatch: + +jobs: + tag-release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: read + + steps: + - 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: + node-version: 22 + + - 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: | + # 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/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..3f779ff3 --- /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: 22 + 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 }} diff --git a/README.md b/README.md index c85f0aea..b1cbad24 100644 --- a/README.md +++ b/README.md @@ -280,29 +280,24 @@ 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: - - `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) - - `major` - Breaking changes (e.g., 0.208.4 → 1.0.0) - -2. **Merge PRs to main** - Release Drafter automatically: + - Updates the draft release notes with PR titles + - You can view the draft at [GitHub Releases](../../releases) - - Creates/updates a draft release with the calculated version - - Generates release notes from PR titles - - Determines version bump based on the highest label used +2. **When ready to release**: -3. **Publish the release** when ready: - - Go to [GitHub Releases](../../releases) - - Review the draft release notes - - Click "Publish release" - - This automatically publishes to NPM + - 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) -### Manual Release (Alternative) + The version bump is automatically calculated based on PR labels: -For hotfixes or special cases, you can manually trigger a release: + - `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) + - `major` - Breaking changes (e.g., 0.208.4 → 1.0.0) -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