ci: restructure workflow to match desktop pattern with separate build and release jobs
This commit is contained in:
@@ -28,14 +28,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||||
echo "Current version: $CURRENT"
|
echo "Current version: $CURRENT"
|
||||||
|
|
||||||
MAJOR=$(echo $CURRENT | cut -d. -f1)
|
MAJOR=$(echo $CURRENT | cut -d. -f1)
|
||||||
MINOR=$(echo $CURRENT | cut -d. -f2)
|
MINOR=$(echo $CURRENT | cut -d. -f2)
|
||||||
PATCH=$(echo $CURRENT | cut -d. -f3)
|
PATCH=$(echo $CURRENT | cut -d. -f3)
|
||||||
NEW_PATCH=$((PATCH + 1))
|
NEW_PATCH=$((PATCH + 1))
|
||||||
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||||||
echo "New version: $NEW_VERSION"
|
echo "New version: $NEW_VERSION"
|
||||||
|
|
||||||
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json
|
||||||
|
|
||||||
grep '"version"' package.json | head -1
|
grep '"version"' package.json | head -1
|
||||||
|
|
||||||
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "SHOULD_BUILD=true" >> $GITHUB_OUTPUT
|
echo "SHOULD_BUILD=true" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
@@ -45,13 +49,9 @@ jobs:
|
|||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
git add package.json
|
git add package.json
|
||||||
git commit -m "chore: bump version to ${{ steps.bump.outputs.VERSION }} [skip ci]"
|
git commit -m "chore: bump version to ${{ steps.bump.outputs.VERSION }} [skip ci]"
|
||||||
for i in 1 2 3; do
|
git push
|
||||||
git pull --rebase origin master && git push && break
|
|
||||||
echo "Push attempt $i failed, retrying..."
|
|
||||||
sleep 3
|
|
||||||
done
|
|
||||||
|
|
||||||
build-and-release:
|
build-android:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: increment-version
|
needs: increment-version
|
||||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
||||||
@@ -60,7 +60,6 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
|
||||||
submodules: false
|
submodules: false
|
||||||
ref: ${{ github.ref_name }}
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ jobs:
|
|||||||
- name: Install dependencies (root)
|
- name: Install dependencies (root)
|
||||||
run: npm ci --prefer-offline
|
run: npm ci --prefer-offline
|
||||||
|
|
||||||
- name: Clean previous cinny dist
|
- name: Clean previous builds
|
||||||
run: rm -rf cinny/dist
|
run: rm -rf cinny/dist
|
||||||
|
|
||||||
- name: Make gradlew executable
|
- name: Make gradlew executable
|
||||||
@@ -97,6 +96,28 @@ jobs:
|
|||||||
- name: Apply overlay and build Android APK
|
- name: Apply overlay and build Android APK
|
||||||
run: npm run android:apk:linux
|
run: npm run android:apk:linux
|
||||||
|
|
||||||
|
- name: Upload APK
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Paarrot-Android.apk
|
||||||
|
path: android/app/build/outputs/apk/debug/Paarrot-*.apk
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [increment-version, build-android]
|
||||||
|
if: always() && needs.build-android.result == 'success'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Pull latest (after version bump)
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: git pull origin master
|
||||||
|
|
||||||
- name: Get version
|
- name: Get version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
@@ -113,8 +134,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
||||||
|
echo "Tag v$VERSION already exists"
|
||||||
echo "exists=true" >> $GITHUB_OUTPUT
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
|
echo "Tag v$VERSION does not exist"
|
||||||
echo "exists=false" >> $GITHUB_OUTPUT
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -126,7 +149,18 @@ jobs:
|
|||||||
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
|
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
|
||||||
git push origin "v${{ steps.version.outputs.VERSION }}"
|
git push origin "v${{ steps.version.outputs.VERSION }}"
|
||||||
|
|
||||||
- name: Create or Update Release
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Prepare release files
|
||||||
|
run: |
|
||||||
|
mkdir -p release-files
|
||||||
|
find artifacts -type f -name "*.apk" -exec cp {} release-files/ \;
|
||||||
|
ls -la release-files/
|
||||||
|
|
||||||
|
- name: Create or Update Gitea Release
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
@@ -135,13 +169,6 @@ jobs:
|
|||||||
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
|
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
|
||||||
REPO="litruv/cinny-mobile"
|
REPO="litruv/cinny-mobile"
|
||||||
|
|
||||||
APK=$(find android/app/build/outputs/apk/debug -name "Paarrot-*.apk" | head -1)
|
|
||||||
if [ -z "$APK" ]; then
|
|
||||||
echo "No APK found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Found APK: $APK"
|
|
||||||
|
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
||||||
|
|
||||||
@@ -154,81 +181,67 @@ jobs:
|
|||||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
||||||
echo "Created release with ID: ${RELEASE_ID}"
|
echo "Created release with ID: ${RELEASE_ID}"
|
||||||
else
|
else
|
||||||
echo "Release exists with ID: ${RELEASE_ID}, deleting existing assets..."
|
echo "Release exists with ID: ${RELEASE_ID}"
|
||||||
|
echo "Deleting existing assets..."
|
||||||
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
|
||||||
for ASSET_ID in $ASSETS; do
|
for ASSET_ID in $ASSETS; do
|
||||||
|
echo "Deleting asset ${ASSET_ID}..."
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Uploading assets..."
|
||||||
|
for FILE in release-files/*; do
|
||||||
FILENAME="Paarrot-${VERSION}.apk"
|
FILENAME="Paarrot-${VERSION}.apk"
|
||||||
echo "Uploading ${FILENAME}..."
|
echo "Uploading ${FILENAME}..."
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@${APK}" \
|
--data-binary "@${FILE}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||||
echo ""
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
echo "Release complete!"
|
echo "Gitea release complete!"
|
||||||
|
|
||||||
- name: Create or Update GitHub Release
|
- name: Create GitHub Release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
TAG_NAME="v${VERSION}"
|
TAG_NAME="v${VERSION}"
|
||||||
API_BASE="https://api.github.com"
|
GITHUB_REPO="Paarrot/Paarrot-Mobile"
|
||||||
REPO="Paarrot/Paarrot-Mobile"
|
|
||||||
|
|
||||||
APK=$(find android/app/build/outputs/apk/debug -name "Paarrot-*.apk" | head -1)
|
RELEASE_ID=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||||
if [ -z "$APK" ]; then
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
||||||
echo "No APK found for GitHub release!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Found APK: $APK"
|
|
||||||
|
|
||||||
RELEASE_RESPONSE=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}")
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id // empty')
|
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
echo "Creating new GitHub release for ${TAG_NAME}..."
|
echo "Creating new GitHub release for ${TAG_NAME}..."
|
||||||
RELEASE_RESPONSE=$(curl -s -X POST \
|
RELEASE_ID=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${GH_TOKEN}" \
|
-H "Authorization: token ${GH_TOKEN}" \
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases")
|
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.id')
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
|
||||||
echo "Created GitHub release with ID: ${RELEASE_ID}"
|
echo "Created GitHub release with ID: ${RELEASE_ID}"
|
||||||
else
|
else
|
||||||
echo "GitHub release exists with ID: ${RELEASE_ID}, deleting existing assets..."
|
echo "GitHub release exists with ID: ${RELEASE_ID}"
|
||||||
ASSETS=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
|
|
||||||
for ASSET_ID in $ASSETS; do
|
|
||||||
curl -s -X DELETE \
|
|
||||||
-H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/assets/${ASSET_ID}"
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILENAME="Paarrot-${VERSION}.apk"
|
echo "Uploading assets to GitHub..."
|
||||||
UPLOAD_URL=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
UPLOAD_URL=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||||
-H "Accept: application/vnd.github+json" \
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
|
||||||
|
for FILE in release-files/*; do
|
||||||
|
FILENAME="Paarrot-${VERSION}.apk"
|
||||||
echo "Uploading ${FILENAME} to GitHub..."
|
echo "Uploading ${FILENAME} to GitHub..."
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${GH_TOKEN}" \
|
-H "Authorization: token ${GH_TOKEN}" \
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@${APK}" \
|
--data-binary "@${FILE}" \
|
||||||
"${UPLOAD_URL}?name=${FILENAME}"
|
"${UPLOAD_URL}?name=${FILENAME}"
|
||||||
echo ""
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
echo "GitHub release complete!"
|
echo "GitHub release complete!"
|
||||||
|
|||||||
Reference in New Issue
Block a user