Skip to content

chore: specify wrangler version 2.0.0 in deployment workflow for both publish steps #237

chore: specify wrangler version 2.0.0 in deployment workflow for both publish steps

chore: specify wrangler version 2.0.0 in deployment workflow for both publish steps #237

Workflow file for this run

# ---------------------------------------------------------------------------------------------
# Copyright (c) Infiniscene, Inc. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# ---------------------------------------------------------------------------------------------
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
name: Tag and release package
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- run: npm ci
- run: npm run build
- name: Get package version
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
# the tag, since any downstream actions (render deploy) won't trigger if it uses the
# default runner credentials.
github_token: ${{ secrets.SERVICEACCOUNT_GITHUB_TOKEN }}
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 }}
access: public