Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: prevent schema from trying to publish existing version #951

Merged
merged 2 commits into from
Jul 31, 2024
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/action-publish-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,42 @@ permissions:
id-token: write

jobs:
check-published-version:
runs-on: ubuntu-latest
outputs:
version-exists: ${{ steps.check-published-version.outputs.version-exists }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'

- name: Fetch package name
id: fetch-package-name
run: echo "PACKAGE_NAME=$(jq -r '.name' package.json)" >> $GITHUB_ENV
working-directory: ${{ env.WORKING_DIRECTORY }}

- name: Check if version exists on NPM
id: check-published-version
run: |
if npm view "${{ env.PACKAGE_NAME }}@${{ inputs.version }}" > /dev/null 2>&1; then
echo "version-exists=true" >> $GITHUB_OUTPUT
echo "Version ${{ inputs.version }} already exists"
else
echo "version-exists=false" >> $GITHUB_OUTPUT
echo "Version ${{ inputs.version }} does not exist"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-schema-to-npm:
runs-on: ubuntu-latest
needs: check-published-version
if: needs.check-published-version.outputs.version-exists == 'false'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
Loading