Skip to content

Commit c4b867a

Browse files
committed
fix: Release mobile stores independently
1 parent 5499a24 commit c4b867a

1 file changed

Lines changed: 61 additions & 30 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,119 @@ on:
66

77
env:
88
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
RELEASE_TAG: ${{ github.event.release.tag_name }}
10+
RELEASE_NOTES: ${{ github.event.release.body }}
911

1012
jobs:
11-
release:
12-
name: Release
13+
common:
14+
name: Read release version
1315
if: ${{ github.repository == 'fossasia/pslab-app' }}
1416
runs-on: ubuntu-latest
15-
17+
outputs:
18+
VERSION_CODE: ${{ steps.download-assets.outputs.VERSION_CODE }}
1619
steps:
1720
- name: Download repository
1821
uses: actions/checkout@v7
1922

20-
- name: Prepare Secrets (Android)
21-
env:
22-
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
23-
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
24-
run: |
25-
bash scripts/prep-android-key.sh
26-
27-
- name: Prepare Secrets (iOS)
28-
if: ${{ github.repository == 'fossasia/pslab-app' }}
29-
env:
30-
ENCRYPTED_IOS_IV: ${{ secrets.ENCRYPTED_IOS_IV }}
31-
ENCRYPTED_IOS_KEY: ${{ secrets.ENCRYPTED_IOS_KEY }}
32-
run: |
33-
bash scripts/prep-ios-key.sh
34-
3523
- name: Download Assets
3624
id: download-assets
3725
run: |
38-
gh release download ${{ github.event.release.tag_name }} --pattern '*.txt'
26+
gh release download "$RELEASE_TAG" --pattern 'versionCode.txt'
3927
read -r version_code < versionCode.txt
40-
echo "VERSION_CODE=$version_code" >> $GITHUB_OUTPUT
28+
[[ "$version_code" =~ ^[0-9]+$ ]] || { echo 'Invalid version code'; exit 1; }
29+
echo "VERSION_CODE=$version_code" >> "$GITHUB_OUTPUT"
30+
31+
android:
32+
name: Release Android
33+
needs: common
34+
runs-on: ubuntu-latest
35+
env:
36+
VERSION_CODE: ${{ needs.common.outputs.VERSION_CODE }}
37+
steps:
38+
- name: Download repository
39+
uses: actions/checkout@v7
4140

41+
- name: Configure Git identity
42+
run: |
4243
git config --global user.name "github-actions[bot]"
4344
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
4445
46+
- name: Prepare Secrets (Android)
47+
env:
48+
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
49+
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
50+
run: |
51+
bash scripts/prep-android-key.sh
52+
4553
- name: Update Fastlane Metadata (Android)
4654
run: |
4755
cd ./android
4856
git clone --branch=fastlane-android --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
4957
cd fastlane
5058
51-
printf "%s" "${{ github.event.release.body }}" > "metadata/android/en-US/changelogs/${{ steps.download-assets.outputs.VERSION_CODE }}.txt"
59+
printf "%s" "$RELEASE_NOTES" > "metadata/android/en-US/changelogs/${VERSION_CODE}.txt"
5260
5361
# Force push to fastlane branch
5462
git checkout --orphan temporary
5563
git add --all .
56-
git commit -am "[Auto] Update changelogs for versionCode: ${{ steps.download-assets.outputs.VERSION_CODE }} ($(date +%Y-%m-%d.%H:%M:%S))"
64+
git commit -am "[Auto] Update changelogs for versionCode: ${VERSION_CODE} ($(date +%Y-%m-%d.%H:%M:%S))"
5765
git branch -D fastlane-android
5866
git branch -m fastlane-android
5967
git push --force origin fastlane-android
6068
6169
- name: Push version to production (Android)
6270
run: |
6371
cd ./android
64-
fastlane promoteToProduction version_code:${{ steps.download-assets.outputs.VERSION_CODE }}
72+
fastlane promoteToProduction version_code:${VERSION_CODE}
6573
if [[ $? -ne 0 ]]; then
6674
exit 1
6775
fi
6876
77+
78+
ios:
79+
name: Release iOS
80+
needs: common
81+
runs-on: ubuntu-latest
82+
env:
83+
VERSION_CODE: ${{ needs.common.outputs.VERSION_CODE }}
84+
steps:
85+
- name: Download repository
86+
uses: actions/checkout@v7
87+
88+
- name: Configure Git identity
89+
run: |
90+
git config --global user.name "github-actions[bot]"
91+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
92+
93+
- name: Prepare Secrets (iOS)
94+
env:
95+
ENCRYPTED_IOS_IV: ${{ secrets.ENCRYPTED_IOS_IV }}
96+
ENCRYPTED_IOS_KEY: ${{ secrets.ENCRYPTED_IOS_KEY }}
97+
run: |
98+
bash scripts/prep-ios-key.sh
99+
69100
- name: Update Fastlane Metadata (iOS)
70101
run: |
71-
cd ./iOS
102+
cd ./ios
72103
git clone --branch=fastlane-ios --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
73104
cd fastlane
74105
75-
printf "%s" "${{ github.event.release.body }}" > "metadata/en-US/release_notes.txt"
106+
printf "%s" "$RELEASE_NOTES" > "metadata/en-US/release_notes.txt"
76107
77108
# Force push to fastlane branch
78109
git checkout --orphan temporary
79110
git add --all .
80-
git commit -am "[Auto] Update changelogs for versionCode: ${{ steps.download-assets.outputs.VERSION_CODE }} ($(date +%Y-%m-%d.%H:%M:%S))"
111+
git commit -am "[Auto] Update changelogs for versionCode: ${VERSION_CODE} ($(date +%Y-%m-%d.%H:%M:%S))"
81112
git branch -D fastlane-ios
82113
git branch -m fastlane-ios
83114
git push --force origin fastlane-ios
84115
85116
- name: Push version to production (iOS)
86117
run: |
87-
cd ./iOS
88-
VERSION_TAG="${{ github.event.release.tag_name }}"
118+
cd ./ios
119+
VERSION_TAG="$RELEASE_TAG"
89120
CLEAN_VERSION="${VERSION_TAG#v}"
90-
fastlane promoteToProduction build_number:${{ steps.download-assets.outputs.VERSION_CODE }} version_name:${CLEAN_VERSION}
121+
fastlane promoteToProduction build_number:${VERSION_CODE} version_name:${CLEAN_VERSION}
91122
if [[ $? -ne 0 ]]; then
92123
exit 1
93-
fi
124+
fi

0 commit comments

Comments
 (0)