Repository navigation
66 lines (56 loc) · 1.96 KB
/
Copy pathpublish-cli.yml
File metadata and controls
66 lines (56 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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"