diff --git a/.github/changelog.json b/.github/changelog.json new file mode 100644 index 00000000..6f5e672b --- /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/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..ba49ed96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,27 +7,49 @@ on: jobs: release: - name: Create Release + name: Create release runs-on: ubuntu-latest + + permissions: + # required for softprops/action-gh-release + contents: write + # required for mikepenz/release-changelog-builder-action + pull-requests: read + 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 + id: publish with: token: ${{ secrets.NPM_TOKEN }} - - name: Create Release + - 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: 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 }} - body: "" + name: Release ${{ github.ref_name }} + 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: diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 00000000..f9d2e462 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,56 @@ +# 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: + workflow_dispatch: + inputs: + version: + description: 'npm version semver level' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + - prerelease + - prepatch + - preminor + - premajor + +jobs: + version: + name: Push ${{ inputs.version }} tag + runs-on: ubuntu-latest + + steps: + - name: Checkout branch + uses: actions/checkout@v4 + with: + # see https://github.com/orgs/community/discussions/25617#discussioncomment-3248494 + token: ${{ secrets.VERSION_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 ${{ 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 }}