From 5c0d0636282f2078357492315e4a3edc4e3573f8 Mon Sep 17 00:00:00 2001 From: Volodymyr Vreshch Date: Tue, 11 Aug 2026 01:42:46 +0200 Subject: [PATCH 1/2] ci: rename publish.yml -> release.yml --- .github/workflows/release.yml | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3deac74 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: Publish Package + +# Publishes @agentage/observability to npm. Manual (workflow_dispatch) or on a release +# commit to master; never on an ordinary push. Requires an NPM_TOKEN repo secret. + +on: + push: + branches: [master] + paths: + - 'package.json' + workflow_dispatch: + +permissions: + contents: write + id-token: write + +env: + NODE_VERSION: '22' + +jobs: + release-gate: + name: Release gate + runs-on: ubuntu-latest + outputs: + is-release: ${{ steps.check.outputs.is-release }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 5 + - id: check + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "is-release=true" >> "$GITHUB_OUTPUT"; exit 0 + fi + MSG=$(git log -1 --pretty=%s) + if echo "$MSG" | grep -qE "(^Release v|^chore: prepare release|^chore\(release\))"; then + echo "is-release=true" >> "$GITHUB_OUTPUT" + else + echo "is-release=false" >> "$GITHUB_OUTPUT" + echo "Not a release commit - skipping publish." + fi + + publish: + name: Publish to npm + needs: [release-gate] + if: needs.release-gate.outputs.is-release == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - name: Skip if version already on npm + id: ver + run: | + name=$(node -p "require('./package.json').name") + version=$(node -p "require('./package.json').version") + if npm view "${name}@${version}" version >/dev/null 2>&1; then + echo "publish=false" >> "$GITHUB_OUTPUT" + echo "${name}@${version} already published." + else + echo "publish=true" >> "$GITHUB_OUTPUT" + fi + echo "tag=v${version}" >> "$GITHUB_OUTPUT" + - if: steps.ver.outputs.publish == 'true' + run: npm run verify + - if: steps.ver.outputs.publish == 'true' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --access public --provenance + - if: steps.ver.outputs.publish == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "${{ steps.ver.outputs.tag }}" -m "Release ${{ steps.ver.outputs.tag }}" + git push origin "${{ steps.ver.outputs.tag }}" From bf2a19d39f7001ae27a06b59fbb165dd947f8cca Mon Sep 17 00:00:00 2001 From: Volodymyr Vreshch Date: Tue, 11 Aug 2026 01:42:47 +0200 Subject: [PATCH 2/2] ci: drop publish.yml (renamed) --- .github/workflows/publish.yml | 79 ----------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 3deac74..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Publish Package - -# Publishes @agentage/observability to npm. Manual (workflow_dispatch) or on a release -# commit to master; never on an ordinary push. Requires an NPM_TOKEN repo secret. - -on: - push: - branches: [master] - paths: - - 'package.json' - workflow_dispatch: - -permissions: - contents: write - id-token: write - -env: - NODE_VERSION: '22' - -jobs: - release-gate: - name: Release gate - runs-on: ubuntu-latest - outputs: - is-release: ${{ steps.check.outputs.is-release }} - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 5 - - id: check - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "is-release=true" >> "$GITHUB_OUTPUT"; exit 0 - fi - MSG=$(git log -1 --pretty=%s) - if echo "$MSG" | grep -qE "(^Release v|^chore: prepare release|^chore\(release\))"; then - echo "is-release=true" >> "$GITHUB_OUTPUT" - else - echo "is-release=false" >> "$GITHUB_OUTPUT" - echo "Not a release commit - skipping publish." - fi - - publish: - name: Publish to npm - needs: [release-gate] - if: needs.release-gate.outputs.is-release == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-node@v6 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - name: Skip if version already on npm - id: ver - run: | - name=$(node -p "require('./package.json').name") - version=$(node -p "require('./package.json').version") - if npm view "${name}@${version}" version >/dev/null 2>&1; then - echo "publish=false" >> "$GITHUB_OUTPUT" - echo "${name}@${version} already published." - else - echo "publish=true" >> "$GITHUB_OUTPUT" - fi - echo "tag=v${version}" >> "$GITHUB_OUTPUT" - - if: steps.ver.outputs.publish == 'true' - run: npm run verify - - if: steps.ver.outputs.publish == 'true' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --access public --provenance - - if: steps.ver.outputs.publish == 'true' - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git tag -a "${{ steps.ver.outputs.tag }}" -m "Release ${{ steps.ver.outputs.tag }}" - git push origin "${{ steps.ver.outputs.tag }}"