Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/prerelease-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: prerelease-canary

permissions:
contents: read
id-token: write

on:
push:
branches:
- main

jobs:
publish:
if: github.repository_owner == 'prismicio'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: "Deprecate previous canary"
run: |
PACKAGE_NAME=$(jq -r ".name" package.json)
PREVIOUS_VERSION=$(npm view "$PACKAGE_NAME" dist-tags.canary 2>/dev/null)
if [ -n "$PREVIOUS_VERSION" ]; then
npm deprecate "$PACKAGE_NAME@$PREVIOUS_VERSION" "Replaced by newer canary version"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm ci
- name: "Generate new version"
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
CURRENT_VERSION=$(jq -r '.version' package.json)
VERSION="${CURRENT_VERSION}-canary.${SHORT_SHA}"
npm version $VERSION --no-git-tag-version
- run: npm publish --provenance --tag canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/prerelease-pr-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: prerelease-pr-cleanup

permissions:
contents: read
id-token: write

on:
pull_request:
types: [closed]

jobs:
cleanup:
if: github.repository_owner == 'prismicio'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: "Deprecate PR prerelease"
run: |
PACKAGE_NAME=$(jq -r ".name" package.json)
TAG="pr-${{ github.event.number }}"
VERSION=$(npm view "$PACKAGE_NAME" dist-tags."$TAG" 2>/dev/null || echo "")
if [ -n "$VERSION" ]; then
npm deprecate "$PACKAGE_NAME@$VERSION" "PR ${{ github.event.number }} was closed"
npm dist-tag rm "$PACKAGE_NAME" "$TAG"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/prerelease-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: prerelease-pr

permissions:
contents: read
id-token: write

on:
pull_request:

jobs:
publish:
if: github.repository_owner == 'prismicio'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: "Deprecate previous PR prerelease"
run: |
PACKAGE_NAME=$(jq -r ".name" package.json)
TAG="pr-${{ github.event.number }}"
PREVIOUS_VERSION=$(npm view "$PACKAGE_NAME" dist-tags."$TAG" 2>/dev/null)
if [ -n "$PREVIOUS_VERSION" ]; then
npm deprecate "$PACKAGE_NAME@$PREVIOUS_VERSION" "Replaced by newer prerelease version"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm ci
- name: "Generate new version"
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
CURRENT_VERSION=$(jq -r '.version' package.json)
VERSION="${CURRENT_VERSION}-pr.${{ github.event.number }}.${SHORT_SHA}"
npm version $VERSION --no-git-tag-version
- run: npm publish --provenance --tag pr-${{ github.event.number }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}