From 5336d158b62a411bc95f451d6f638885b786114d Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Tue, 20 May 2025 22:31:39 -0500 Subject: [PATCH 1/9] Update action versions & replace release action Updated the versions of the used actions (where I noticed possible). Also replaced actions/create-release with softprops/action-gh-release because the former was archived in 2021. Based on a single suggestion I saw somewhere online, it's best to --ignore-scripts with npm ci. So I did that here too. --- .github/workflows/ci.yml | 9 +++++---- .github/workflows/docs.yml | 8 ++++---- .github/workflows/release.yml | 24 +++++++++++++++--------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c57ac2ad..ad84de46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,15 +10,16 @@ jobs: ci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: | docker pull ghcr.io/osgeo/gdal:ubuntu-small-latest ; docker run -i --rm -v `pwd`/test/data:/data ghcr.io/osgeo/gdal:ubuntu-small-latest bash -c "apt-get update && apt-get -y install imagemagick libtiff-tools wget && cd /data && ./setup_data.sh" - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: 20.x - - run: npm ci + node-version: 22.x + - run: npm ci --ignore-scripts + - run: npm rebuild - run: npm run build - run: npm test - name: action-slack diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2fa60f7b..c310d88e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/checkout@v4 + - name: Use Node.js 22.x + uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: 22.x - run: npm ci - run: npm run docs - name: Deploy pages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36ea6787..6c72f322 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,25 +7,31 @@ on: jobs: release: - name: Create Release + name: Create release runs-on: ubuntu-latest + + permissions: + # required for softprops/action-gh-release + contents: write + steps: - name: Checkout code - uses: actions/checkout@v2 - - run: npm install + uses: actions/checkout@v4 + - run: npm ci --ignore-scripts + # npm run prepare runs the build step for publish and pack + - run: npm rebuild && npm run prepare - run: npm run docs - - uses: JS-DevTools/npm-publish@v1 + - uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - - name: Create Release + - name: Create release id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + name: Release ${{ github.ref_name }} body: "" + generate_release_notes: true draft: true prerelease: false - name: action-slack From a0ea29311f25b840a5f958d9c84254e084ef0022 Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Tue, 20 May 2025 22:49:04 -0500 Subject: [PATCH 2/9] Customize GH release notes & add tarball I wasn't extremely happy with the default github-generated release notes, specifically the changelog tag detection, so I used the suggestions I found in the softprops repo: mikepenz's release-changelog-builder-action. Added .github/changelog.json to customize the labels, categories, and output templates for the release notes. For it to work how I'd like, I had to manually construct the compare link from the action's detected tags and manually construct the NPM package url. Also had to add a manual npm pack step in order to provide the .tgz in the GitHub release assets, but that can be removed if desired. --- .github/changelog.json | 31 +++++++++++++++++++++++++++++++ .github/workflows/release.yml | 20 +++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/changelog.json diff --git a/.github/changelog.json b/.github/changelog.json new file mode 100644 index 00000000..5ba9eb78 --- /dev/null +++ b/.github/changelog.json @@ -0,0 +1,31 @@ +{ + "categories": [ + { + "title": "## โš™๏ธ Breaking", + "labels": ["breaking"] + }, + { + "title": "## ๐Ÿš€ Features", + "labels": ["feature", "enhancement"] + }, + { + "title": "## ๐Ÿ› Fixes", + "labels": ["fix", "bugfix"] + }, + { + "title": "## ๐Ÿ“œ Documentation", + "labels": ["documentation", "docs"] + }, + { + "title": "## ๐Ÿ› ๏ธ Infrastructure", + "labels": ["dependencies", "maintenance", "ci"] + }, + { + "title": "## ๐Ÿ’ฌ Uncategorized", + "labels": [] + } + ], + "ignore_labels": ["ignore", "ci-ignore"], + "template": "#{{CHANGELOG}}", + "pr_template": "- #{{TITLE}} (##{{NUMBER}} by @#{{AUTHOR}})" +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c72f322..d191dbeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,16 +24,30 @@ jobs: - uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} + # see https://github.com/softprops/action-gh-release/pull/372#issuecomment-1642643937 + - name: Create release notes + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v5 + with: + configuration: '.github/changelog.json' + ignorePreReleases: ${{ ! contains(github.ref_name, '-') }} + - name: Create tarball + run: npm pack --ignore-scripts - name: Create release id: create_release uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.ref }} name: Release ${{ github.ref_name }} - body: "" - generate_release_notes: true + body: | + ${{ steps.build_changelog.outputs.changelog }} + + **${{ contains(github.ref_name, '-') && 'Prerelease' || 'Full' }} changelog:** ${{ github.server_url }}/${{ github.repository }}/compare/${{ steps.build_changelog.outputs.fromTag }}...${{ steps.build_changelog.outputs.toTag }} + **NPM release:** https://npmjs.com/package/${{ steps.publish.outputs.name }}/v/${{ steps.publish.outputs.version }} draft: true - prerelease: false + prerelease: ${{ contains(github.ref_name, '-') }} + files: | + *.tgz - name: action-slack uses: 8398a7/action-slack@v3.8.0 with: From 06107c73c47fb025d4726bee0fa7e63d192e678d Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Tue, 20 May 2025 22:54:15 -0500 Subject: [PATCH 3/9] Add version.yml workflow for on-click release Added a new workflow file: version.yml. This workflow simply runs npm version with the desired values and pushes the commit and tag back to the repository. Along with release.yml, this functionally creates on-demand npm and github releases from the click of a button. This workflow requires a PAT in-place of the GITHUB_TOKEN, as the workflow default GITHUB_TOKEN will **not** trigger GitHub Actions. --- .github/workflows/version.yml | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/version.yml diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 00000000..480ae2f7 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,61 @@ +name: Push version + +on: + workflow_dispatch: + inputs: + version: + description: 'npm version semver level' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + - prerelease + - prepatch + - preminor + - premajor + preId: + description: 'Prerelease identifier (required with pre-*)' + required: false + type: string + +jobs: + validate: + name: Validate workflow inputs + runs-on: ubuntu-latest + + steps: + - name: Invalid prerelease identifier + if: ${{ startsWith(github.event.inputs.version, 'pre') && !github.event.inputs.preId }} + run: | + echo "Error: 'preId' input is required with 'pre-*' version." + exit 1 + + version: + name: Push ${{ inputs.version }} tag + runs-on: ubuntu-latest + + needs: [validate] + + steps: + - name: Checkout branch + uses: actions/checkout@v4 + with: + # see https://github.com/orgs/community/discussions/25617#discussioncomment-3248494 + token: ${{ secrets.RELEASE_TOKEN }} + # requires contents: write permission for this repo + # used by `git push` at the end + - uses: actions/setup-node@v4 + with: + node-version: 22.x + - name: Configure git user + # this step is necessary for `npm version` to succeed + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + - name: NPM version + run: echo "version=$(npm version ${{ inputs.version }}${{ inputs.preId && format(' --preid {0}', inputs.preId) || '' }})" >> $GITHUB_ENV + - name: Git push + run: git push && git push origin ${{ env.version }} From 7f87df49b62ff2b917a4fab1d5b84ed8375b5886 Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Tue, 20 May 2025 23:46:28 -0500 Subject: [PATCH 4/9] Fix release permissions, cleanup Whoops, forgot to add back the pull-request: read permissions while trying to keep a clean history and diff. And I accidentally left a comment that I didn't mean to. Also decided to change the "Push version" action to "Push new version". --- .github/workflows/release.yml | 3 ++- .github/workflows/version.yml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d191dbeb..9a6fdcd5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,8 @@ jobs: permissions: # required for softprops/action-gh-release contents: write + # required for mikepenz/release-changelog-builder-action + pull-requests: read steps: - name: Checkout code @@ -24,7 +26,6 @@ jobs: - uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - # see https://github.com/softprops/action-gh-release/pull/372#issuecomment-1642643937 - name: Create release notes id: build_changelog uses: mikepenz/release-changelog-builder-action@v5 diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 480ae2f7..9ad2760e 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -1,4 +1,4 @@ -name: Push version +name: Push new version on: workflow_dispatch: @@ -17,7 +17,7 @@ on: - preminor - premajor preId: - description: 'Prerelease identifier (required with pre-*)' + description: 'Prerelease identifier (required with pre*)' required: false type: string @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v4 with: # see https://github.com/orgs/community/discussions/25617#discussioncomment-3248494 - token: ${{ secrets.RELEASE_TOKEN }} + token: ${{ secrets.VERSION_TOKEN }} # requires contents: write permission for this repo # used by `git push` at the end - uses: actions/setup-node@v4 From 30984debbae4dd8ff331d43581920b7b9ca6a39c Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Mon, 2 Jun 2025 10:09:06 -0500 Subject: [PATCH 5/9] Remove emojis from release changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per PR suggestionโ€” and to align with personal preferenceโ€” removed the emojis from the generated release notes category titles. --- .github/changelog.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/changelog.json b/.github/changelog.json index 5ba9eb78..6f5e672b 100644 --- a/.github/changelog.json +++ b/.github/changelog.json @@ -1,27 +1,27 @@ { "categories": [ { - "title": "## โš™๏ธ Breaking", + "title": "## Breaking", "labels": ["breaking"] }, { - "title": "## ๐Ÿš€ Features", + "title": "## Features", "labels": ["feature", "enhancement"] }, { - "title": "## ๐Ÿ› Fixes", + "title": "## Fixes", "labels": ["fix", "bugfix"] }, { - "title": "## ๐Ÿ“œ Documentation", + "title": "## Documentation", "labels": ["documentation", "docs"] }, { - "title": "## ๐Ÿ› ๏ธ Infrastructure", + "title": "## Infrastructure", "labels": ["dependencies", "maintenance", "ci"] }, { - "title": "## ๐Ÿ’ฌ Uncategorized", + "title": "## Uncategorized", "labels": [] } ], From bd7efb63faf40008d48d4271a427a08ffbb30842 Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Mon, 2 Jun 2025 10:25:00 -0500 Subject: [PATCH 6/9] Retry ci.yml Not sure why the emoji commit broke CI, but it seems transient... testing... From 03cec9d01aa5c2773a84c40383ab5af149c0e73f Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Thu, 5 Jun 2025 12:10:23 -0500 Subject: [PATCH 7/9] Fix release.yml step outputs Whoops, forgot to put id: publish on the npm-publish step, so the generated release notes wouldn't have had the necessary values from that step (or it would crash... not 100% sure). --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a6fdcd5..ba49ed96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,7 @@ jobs: - run: npm rebuild && npm run prepare - run: npm run docs - uses: JS-DevTools/npm-publish@v3 + id: publish with: token: ${{ secrets.NPM_TOKEN }} - name: Create release notes From 513440f006c34e372777dfa8525b5cfc56365ad5 Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Thu, 5 Jun 2025 18:40:54 -0500 Subject: [PATCH 8/9] Switch version.yml to hardcoded preid 'beta' After discussion in the PR, I've decided it is actually better to reduce the complexity and hardcode the preId when making pre* level versions. Leaving my comment blocks in this commit for posterity, but I'll delete them in the next because I don't think it needs to exist in master. --- .github/workflows/version.yml | 59 ++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 9ad2760e..9ce22abf 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -9,35 +9,47 @@ on: default: 'patch' type: choice options: - - patch - - minor - - major - - prerelease - - prepatch - - preminor - - premajor - preId: - description: 'Prerelease identifier (required with pre*)' - required: false - type: string + - patch + - minor + - major + - prerelease + - prepatch + - preminor + - premajor + # Uncomment the following for text input preId + # preId: + # description: 'Prerelease identifier (required with pre*)' + # required: false + # type: string + # Uncomment the following for selection preId + # preId: + # description: 'Prerelease identifier (used with pre*)' + # required: true + # default: 'beta' + # type: choice + # options: + # - alpha + # - beta jobs: - validate: - name: Validate workflow inputs - runs-on: ubuntu-latest + # Uncomment the following step if using text input preId + # validate: + # name: Validate workflow inputs + # runs-on: ubuntu-latest - steps: - - name: Invalid prerelease identifier - if: ${{ startsWith(github.event.inputs.version, 'pre') && !github.event.inputs.preId }} - run: | - echo "Error: 'preId' input is required with 'pre-*' version." - exit 1 + # steps: + # - name: Invalid prerelease identifier + # if: ${{ startsWith(github.event.inputs.version, 'pre') && !github.event.inputs.preId }} + # run: | + # echo "Error: 'preId' input is required with 'pre-*' version." + # exit 1 version: name: Push ${{ inputs.version }} tag runs-on: ubuntu-latest - needs: [validate] + # Uncomment the following line if using the validate step above + # needs: [validate] steps: - name: Checkout branch @@ -56,6 +68,9 @@ jobs: git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor }}@users.noreply.github.com" - name: NPM version - run: echo "version=$(npm version ${{ inputs.version }}${{ inputs.preId && format(' --preid {0}', inputs.preId) || '' }})" >> $GITHUB_ENV + # Uncomment the following line if using preId input + # run: echo "version=$(npm version ${{ inputs.version }}${{ startsWith(inputs.version, 'pre') && format(' --preid {0}', inputs.preId) || '' }})" >> "$GITHUB_ENV" + # Uncomment the following line for hardcoded 'beta' preId + run: echo "version=$(npm version ${{ inputs.version }})${{ startsWith(inputs.version, 'pre') && '--preid beta' || ''}}" >> "$GITHUB_ENV" - name: Git push run: git push && git push origin ${{ env.version }} From 5168ee2e0fdf0525bbdba2280ccce0000376ecbe Mon Sep 17 00:00:00 2001 From: Cameron Woodbury Date: Thu, 5 Jun 2025 18:51:39 -0500 Subject: [PATCH 9/9] Improve comment blocks in version.yml Removed the unnecessary "optional" commented code blocks from version.yml, and replaced them with a small explainer annotation at the top. --- .github/workflows/version.yml | 50 +++++++++++------------------------ 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 9ce22abf..f9d2e462 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -1,3 +1,15 @@ +# Create and push the commit and tag created from npm version +# +# From the Actions page on GitHub, users (with write permissions) can select +# the desired release and this action will handle running npm version +# and pushing the tag to the repository. +# +# Due to the VERSION_TOKEN, the tag push will trigger release.yml, which handles +# releasing to npm and GitHub releases. +# +# With pre* versions (prerelease, prepatch, etc.), the tag will be created with +# --preid beta. Currently, they are released normally, to --tag latest on npm. + name: Push new version on: @@ -16,41 +28,12 @@ on: - prepatch - preminor - premajor - # Uncomment the following for text input preId - # preId: - # description: 'Prerelease identifier (required with pre*)' - # required: false - # type: string - # Uncomment the following for selection preId - # preId: - # description: 'Prerelease identifier (used with pre*)' - # required: true - # default: 'beta' - # type: choice - # options: - # - alpha - # - beta jobs: - # Uncomment the following step if using text input preId - # validate: - # name: Validate workflow inputs - # runs-on: ubuntu-latest - - # steps: - # - name: Invalid prerelease identifier - # if: ${{ startsWith(github.event.inputs.version, 'pre') && !github.event.inputs.preId }} - # run: | - # echo "Error: 'preId' input is required with 'pre-*' version." - # exit 1 - version: name: Push ${{ inputs.version }} tag runs-on: ubuntu-latest - # Uncomment the following line if using the validate step above - # needs: [validate] - steps: - name: Checkout branch uses: actions/checkout@v4 @@ -67,10 +50,7 @@ jobs: run: | git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - name: NPM version - # Uncomment the following line if using preId input - # run: echo "version=$(npm version ${{ inputs.version }}${{ startsWith(inputs.version, 'pre') && format(' --preid {0}', inputs.preId) || '' }})" >> "$GITHUB_ENV" - # Uncomment the following line for hardcoded 'beta' preId - run: echo "version=$(npm version ${{ inputs.version }})${{ startsWith(inputs.version, 'pre') && '--preid beta' || ''}}" >> "$GITHUB_ENV" - - name: Git push + - name: npm version ${{ inputs.version }} + run: echo "version=$(npm version ${{ inputs.version }}${{ startsWith(inputs.version, 'pre') && '--preid beta' || '' }})" >> "$GITHUB_ENV" + - name: git push run: git push && git push origin ${{ env.version }}