Repository navigation
v0.9.28: mship contract updates, library #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish-cli | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'packages/cli/**' | |
| permissions: | |
| contents: read | |
| # A newer push waits for the running publish rather than racing its version check. | |
| concurrency: | |
| group: publish-cli-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| name: publish | |
| runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 | |
| with: | |
| persist-credentials: false | |
| - name: Setup workspace | |
| uses: ./.github/actions/setup | |
| with: | |
| provider: ${{ vars.CI_PROVIDER }} | |
| node-version: '22' | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Build package | |
| working-directory: packages/cli | |
| run: bun run build | |
| - name: Get package version | |
| id: package_version | |
| working-directory: packages/cli | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Check if version already exists | |
| id: version_check | |
| env: | |
| VERSION: ${{ steps.package_version.outputs.version }} | |
| run: | | |
| if npm view "simstudio@$VERSION" version &> /dev/null; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.version_check.outputs.exists == 'false' | |
| working-directory: packages/cli | |
| run: npm publish --access=public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Log skipped publish | |
| if: steps.version_check.outputs.exists == 'true' | |
| env: | |
| VERSION: ${{ steps.package_version.outputs.version }} | |
| run: echo "Skipped publishing because version $VERSION already exists on npm" |