updated ci/cd to add releases and testing claude code on my project
This commit is contained in:
@@ -82,3 +82,93 @@ jobs:
|
|||||||
ssh -i ~/.ssh/key \
|
ssh -i ~/.ssh/key \
|
||||||
"${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}" \
|
"${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}" \
|
||||||
"cd ~/programs/etf-oglasi-server && docker compose pull && docker compose up -d"
|
"cd ~/programs/etf-oglasi-server && docker compose pull && docker compose up -d"
|
||||||
|
|
||||||
|
mobile-release:
|
||||||
|
name: Mobile Release
|
||||||
|
needs: backend-unit-tests
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: frontend
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ env.JAVA_VERSION }}
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: ${{ env.JAVA_VERSION }}
|
||||||
|
|
||||||
|
- name: Set up Android SDK
|
||||||
|
uses: android-actions/setup-android@v3
|
||||||
|
|
||||||
|
- name: Accept Android SDK licenses
|
||||||
|
run: yes | sdkmanager --licenses > /dev/null || true
|
||||||
|
|
||||||
|
- name: Determine next mobile version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
git fetch --tags
|
||||||
|
LAST=$(git tag -l 'mobile-v*' | sed 's/mobile-v//' | sort -n | tail -1)
|
||||||
|
NEXT=$(( ${LAST:-0} + 1 ))
|
||||||
|
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=mobile-v$NEXT" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Stamp app version
|
||||||
|
run: node scripts/set-mobile-version.js ${{ steps.version.outputs.next }}
|
||||||
|
|
||||||
|
- name: Restore Firebase config
|
||||||
|
run: echo "${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" | base64 -d > google-services.json
|
||||||
|
|
||||||
|
- name: Restore env
|
||||||
|
run: echo "EXPO_PUBLIC_API_URL=${{ secrets.EXPO_PUBLIC_API_URL }}" > .env
|
||||||
|
|
||||||
|
- name: Restore signing keystore
|
||||||
|
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > ksan.dev.keystore
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Prebuild Android project
|
||||||
|
run: npx expo prebuild -p android --no-install
|
||||||
|
|
||||||
|
- name: Build signed release APK
|
||||||
|
working-directory: frontend/android
|
||||||
|
run: |
|
||||||
|
./gradlew assembleRelease \
|
||||||
|
-Pandroid.injected.signing.store.file="$PWD/../ksan.dev.keystore" \
|
||||||
|
-Pandroid.injected.signing.store.password="${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
|
||||||
|
-Pandroid.injected.signing.key.alias="${{ secrets.ANDROID_KEY_ALIAS }}" \
|
||||||
|
-Pandroid.injected.signing.key.password="${{ secrets.ANDROID_KEY_PASSWORD }}"
|
||||||
|
|
||||||
|
- name: Locate APK
|
||||||
|
id: apk
|
||||||
|
run: |
|
||||||
|
APK=$(find android/app/build/outputs/apk/release -name "*.apk" | head -n1)
|
||||||
|
OUT="etfoglasi-${{ steps.version.outputs.tag }}.apk"
|
||||||
|
cp "$APK" "$OUT"
|
||||||
|
echo "path=frontend/$OUT" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "name=$OUT" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
run: |
|
||||||
|
RELEASE_ID=$(curl -sf -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEARELEASE_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${{ steps.version.outputs.tag }}\",\"target_commitish\":\"${{ github.sha }}\",\"name\":\"${{ steps.version.outputs.tag }}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"https://git.${{ secrets.DOMAIN }}/api/v1/repos/${{ secrets.REGISTRY_USER }}/etf-oglasi/releases" \
|
||||||
|
| node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).id")
|
||||||
|
|
||||||
|
curl -sf -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEARELEASE_TOKEN }}" \
|
||||||
|
-F "attachment=@${{ steps.apk.outputs.path }}" \
|
||||||
|
"https://git.${{ secrets.DOMAIN }}/api/v1/repos/${{ secrets.REGISTRY_USER }}/etf-oglasi/releases/$RELEASE_ID/assets?name=${{ steps.apk.outputs.name }}"
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// Used by CI to stamp a mobile release build with its version number.
|
||||||
|
// Updates version.json (read by hooks/useUpdatecheck.tsx) and app.json's
|
||||||
|
// android.versionCode/versionName so the build, the in-app update check,
|
||||||
|
// and the Gitea release tag (mobile-vN) all agree on the same number.
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const version = parseInt(process.argv[2], 10);
|
||||||
|
if (!Number.isInteger(version) || version <= 0) {
|
||||||
|
console.error('Usage: node set-mobile-version.js <positive integer>');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = path.join(__dirname, '..');
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(root, 'version.json'),
|
||||||
|
JSON.stringify({ version }, null, 2) + '\n',
|
||||||
|
);
|
||||||
|
|
||||||
|
const appJsonPath = path.join(root, 'app.json');
|
||||||
|
const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'));
|
||||||
|
appJson.expo.version = `1.0.${version}`;
|
||||||
|
appJson.expo.android = appJson.expo.android ?? {};
|
||||||
|
appJson.expo.android.versionCode = version;
|
||||||
|
fs.writeFileSync(appJsonPath, JSON.stringify(appJson, null, 2) + '\n');
|
||||||
|
|
||||||
|
console.log(`Stamped mobile version ${version}`);
|
||||||
Reference in New Issue
Block a user