Skip to content

Update changelog for pluggable-widgets-tools #89

Update changelog for pluggable-widgets-tools

Update changelog for pluggable-widgets-tools #89

Workflow file for this run

name: Publish npm packages
# To test this flow, push a `test-v*` tag.
# This will check against the real npmjs.com/package/test package, but won't actually publish.
on:
push:
tags:
- "pluggable-widgets-tools-v*"
- "generator-widget-v*"
- "test-v*"
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
discover:
name: Discover packages to publish
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.export.outputs.releases }}
steps:
- name: Checking-out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Get tags for HEAD
id: export
run: |
echo "releases=$(
(
for tag in $(git tag --points-at HEAD); do
package=${tag%-v*}
version=${tag##*-v}
# Without a file argument, jq will wait for stdin, unless you specify --null-input.
# By default jq pretty prints json. We need all of it on 1 line, so we use --compact-output here.
jq --null-input --compact-output --arg p $package --arg v $version '{ package: $p, version: $v }'
done
# The github outputs don't support unescaped newlines. So we use compact output here as well.
) | jq --compact-output --slurp '.'
)" >> "$GITHUB_OUTPUT"
publish:
name: "Publish NPM packages"
runs-on: ubuntu-latest
needs: discover
if: ${{ needs.discover.outputs.releases != '[]' }}
strategy:
fail-fast: false
matrix:
release: ${{ fromJSON(needs.discover.outputs.releases) }}
environment: ${{ matrix.release.package }}
steps:
- name: Check-out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
- name: Setup node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: ".nvmrc"
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Pack package
if: ${{ matrix.release.package != 'test' }}
working-directory: ./packages/${{ matrix.release.package }}
run: pnpm pack
- name: Setup node for npm publishing
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '24' # Includes a version of npm higher than 11.5.1, which is needed for OIDC
- name: Release Tag
run: |
package="$(echo "${{matrix.release.package}}" | sed -E '/^test$/! s/^/@mendix\//')" # Prefix all packages except test
release="${{ matrix.release.version }}"
latest="$(npm view $package dist-tags.latest)"
older="$(npx semver@7.8.5 "$latest" "$release" 2>/dev/null | head -n 1)"
tag="latest"
if [[ "$latest" != "$older" ]]; then
tag="$(echo "$release" | sed -E 's/^([0-9]+\.[0-9]+).[0-9]+$/\1-latest/')"
fi
printf 'Using release tag %s' "$tag"
printf 'release_tag=%s' "$tag" >> "$GITHUB_ENV"
- name: Publish package
working-directory:
run: |
cmd="npm publish --tag $release_tag ./packages/${{ matrix.release.package }}/mendix-${{ matrix.release.package }}-${{matrix.release.version }}.tgz"
if [[ "${{ matrix.release.package }}" == "test" ]]; then
echo "$cmd"
else
$cmd
fi