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
6 changes: 4 additions & 2 deletions .github/workflows/deploy-renderer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
id: package-version
uses: martinbeentjes/npm-get-version-action@main

- uses: cloudflare/wrangler-action@2.0.0
- uses: cloudflare/wrangler-action@v3
name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
with:
wranglerVersion: "2.0.0"
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: './build/hosted-renderer'
Expand All @@ -42,10 +43,11 @@ jobs:
node directory-to-kv.js --prefix version/${{ steps.package-version.outputs.current-version }} --source ../../renderer/dist --destination renderer.json
wrangler kv:bulk put renderer.json --binding=SCENELESS_KV

- uses: cloudflare/wrangler-action@2.0.0
- uses: cloudflare/wrangler-action@v3
name: Publish latest
if: ${{github.ref == 'refs/heads/main' }}
with:
wranglerVersion: "2.0.0"
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: './build/hosted-renderer'
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
push:
branches:
- main

name: Tag and release package
jobs:
publish:
Expand All @@ -27,8 +26,29 @@ jobs:
id: package-version
uses: martinbeentjes/npm-get-version-action@main

- name: Check if version already exists on npm
id: check_version_exists
run: |
PACKAGE_NAME="@api.stream/studio-kit"
PACKAGE_VERSION="${{ steps.package-version.outputs.current-version }}"

echo "Checking if version $PACKAGE_VERSION of $PACKAGE_NAME already exists on npm..."

# Fetch all published versions as a JSON array
NPM_VERSIONS_JSON=$(npm view "$PACKAGE_NAME" versions --json || echo "[]")

# Check if the current version exists in the JSON array using jq
if echo "$NPM_VERSIONS_JSON" | jq -e ".[] == \"$PACKAGE_VERSION\"" > /dev/null; then
echo "✅ Version $PACKAGE_VERSION already exists on npm. Skipping publish."
echo "version_exists=true" >> "$GITHUB_OUTPUT"
else
echo "🚀 Version $PACKAGE_VERSION does not exist on npm. Proceeding with publish."
echo "version_exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Tag commit with release version
id: tag_version
if: steps.check_version_exists.outputs.version_exists != 'true'
uses: mathieudutour/[email protected]
with:
# Due to a quirk of GitHub actions, we must use an access token of a real user to create
Expand All @@ -38,13 +58,15 @@ jobs:
custom_tag: ${{ steps.package-version.outputs.current-version}}

- name: Create a GitHub release
if: steps.check_version_exists.outputs.version_exists != 'true'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

- name: Publish package to NPM
if: steps.check_version_exists.outputs.version_exists != 'true'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
Expand Down