Skip to content

Commit aa2f0e2

Browse files
authored
chore: possibility to patch old versions via ci (#834)
* chore: possibility to patch old versions via ci * chore: changed order of ifs * fix: changed ifs syntax * fix: added placeholder for trunkated version
1 parent 32f2c66 commit aa2f0e2

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/npm-audio-package-build.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
description: 'Whether to publish as a latest build'
1010
required: true
1111
type: boolean
12+
old-version-patch:
13+
description: 'Whether to publish as a patch to an old version'
14+
required: true
15+
type: boolean
1216

1317
permissions:
1418
id-token: write
@@ -28,7 +32,8 @@ jobs:
2832
id-token: write
2933
env:
3034
AUDIO_API_DIR: packages/react-native-audio-api
31-
AUDIO_API_VERSION: PLACEHOLDER
35+
AUDIO_API_VERSION: PLACEHOLDER # all placeholders to be replaced during the run
36+
TRUNKATED_VERSION: PLACEHOLDER
3237
PACKAGE_NAME: PLACEHOLDER
3338
TAG: PLACEHOLDER
3439
steps:
@@ -50,17 +55,30 @@ jobs:
5055
run: |
5156
VERSION=$(jq -r .version package.json)
5257
echo "AUDIO_API_VERSION=$VERSION" >> $GITHUB_ENV
58+
TRUNKATED_VERSION=$(echo $VERSION | cut -d. -f1,2)
59+
echo "TRUNKATED_VERSION=$TRUNKATED_VERSION" >> $GITHUB_ENV
5360
5461
- name: Assert AUDIO_API_VERSION
5562
if: ${{ env.AUDIO_API_VERSION == 'PLACEHOLDER' }}
5663
run: exit 1 # this should never happen
5764

65+
- name: Assert TRUNKATED_VERSION
66+
if: ${{ env.TRUNKATED_VERSION == 'PLACEHOLDER' }}
67+
run: exit 1 # this should never happen
68+
5869
- name: Install monorepo dependencies
5970
run: yarn install --immutable
6071

6172
- name: Set tag
6273
run: |
63-
if [[ "${{ inputs.latest-build }}" != "true" ]]; then
74+
if [[ "${{ inputs.old-version-patch }}" == "true" ]]; then
75+
CURRENT_VERSION=$(npm view react-native-audio-api version | cut -d. -f1,2)
76+
if [[ "$CURRENT_VERSION" == "${{ env.TRUNKATED_VERSION }}" ]]; then
77+
echo "Old version patch requested but current published version matches package version. Exiting."
78+
exit 1
79+
fi
80+
echo "TAG=rn-audio-api-${{ env.TRUNKATED_VERSION }}" >> $GITHUB_ENV
81+
elif [[ "${{ inputs.latest-build }}" != "true" ]]; then
6482
echo "TAG=audio-api-nightly" >> $GITHUB_ENV
6583
else
6684
echo "TAG=latest" >> $GITHUB_ENV
@@ -74,7 +92,7 @@ jobs:
7492
id: build
7593
working-directory: ${{ env.AUDIO_API_DIR }}
7694
run: |
77-
if [[ "${{ inputs.latest-build }}" != "true" ]]; then
95+
if [[ "${{ inputs.latest-build }}" != "true" && "${{ inputs.old-version-patch }}" != "true"]]; then
7896
./scripts/create-package.sh generate_nightly_version
7997
else
8098
./scripts/create-package.sh

0 commit comments

Comments
 (0)