diff --git a/.github/workflows/npm-audio-package-build.yml b/.github/workflows/npm-audio-package-build.yml index 48ec45c1b..7a7ba5b69 100644 --- a/.github/workflows/npm-audio-package-build.yml +++ b/.github/workflows/npm-audio-package-build.yml @@ -9,6 +9,10 @@ on: description: 'Whether to publish as a latest build' required: true type: boolean + old-version-patch: + description: 'Whether to publish as a patch to an old version' + required: true + type: boolean permissions: id-token: write @@ -28,7 +32,8 @@ jobs: id-token: write env: AUDIO_API_DIR: packages/react-native-audio-api - AUDIO_API_VERSION: PLACEHOLDER + AUDIO_API_VERSION: PLACEHOLDER # all placeholders to be replaced during the run + TRUNKATED_VERSION: PLACEHOLDER PACKAGE_NAME: PLACEHOLDER TAG: PLACEHOLDER steps: @@ -50,17 +55,30 @@ jobs: run: | VERSION=$(jq -r .version package.json) echo "AUDIO_API_VERSION=$VERSION" >> $GITHUB_ENV + TRUNKATED_VERSION=$(echo $VERSION | cut -d. -f1,2) + echo "TRUNKATED_VERSION=$TRUNKATED_VERSION" >> $GITHUB_ENV - name: Assert AUDIO_API_VERSION if: ${{ env.AUDIO_API_VERSION == 'PLACEHOLDER' }} run: exit 1 # this should never happen + - name: Assert TRUNKATED_VERSION + if: ${{ env.TRUNKATED_VERSION == 'PLACEHOLDER' }} + run: exit 1 # this should never happen + - name: Install monorepo dependencies run: yarn install --immutable - name: Set tag run: | - if [[ "${{ inputs.latest-build }}" != "true" ]]; then + if [[ "${{ inputs.old-version-patch }}" == "true" ]]; then + CURRENT_VERSION=$(npm view react-native-audio-api version | cut -d. -f1,2) + if [[ "$CURRENT_VERSION" == "${{ env.TRUNKATED_VERSION }}" ]]; then + echo "Old version patch requested but current published version matches package version. Exiting." + exit 1 + fi + echo "TAG=rn-audio-api-${{ env.TRUNKATED_VERSION }}" >> $GITHUB_ENV + elif [[ "${{ inputs.latest-build }}" != "true" ]]; then echo "TAG=audio-api-nightly" >> $GITHUB_ENV else echo "TAG=latest" >> $GITHUB_ENV @@ -74,7 +92,7 @@ jobs: id: build working-directory: ${{ env.AUDIO_API_DIR }} run: | - if [[ "${{ inputs.latest-build }}" != "true" ]]; then + if [[ "${{ inputs.latest-build }}" != "true" && "${{ inputs.old-version-patch }}" != "true"]]; then ./scripts/create-package.sh generate_nightly_version else ./scripts/create-package.sh