This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
TAG="$1"
|
|
||||||
TITLE="$2"
|
|
||||||
NOTES_FILE="$3"
|
|
||||||
ASSET_PATH="$4"
|
|
||||||
|
|
||||||
API_URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
|
||||||
|
|
||||||
# Create release
|
|
||||||
RELEASE_RESPONSE=$(curl -s -X POST "$API_URL" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"${TAG}\",
|
|
||||||
\"name\": \"${TITLE}\",
|
|
||||||
\"body\": $(jq -Rs . < "$NOTES_FILE")
|
|
||||||
}")
|
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Failed to create release:"
|
|
||||||
echo "$RELEASE_RESPONSE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Created release with ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
# Upload asset
|
|
||||||
ASSET_NAME=$(basename "$ASSET_PATH")
|
|
||||||
UPLOAD_URL="${API_URL}/${RELEASE_ID}/assets?name=${ASSET_NAME}"
|
|
||||||
|
|
||||||
curl -s -X POST "$UPLOAD_URL" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@${ASSET_PATH}"
|
|
||||||
|
|
||||||
echo "Uploaded asset: $ASSET_NAME"
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
VERSION="${1#v}"
|
|
||||||
VERSION_CODE=$(grep 'versionCode = ' app/build.gradle.kts | sed 's/.*versionCode = \([0-9]*\).*/\1/')
|
|
||||||
FASTLANE_DIR="fastlane/metadata/android/en-US/changelogs"
|
|
||||||
|
|
||||||
mkdir -p "$FASTLANE_DIR"
|
|
||||||
|
|
||||||
awk -v ver="$VERSION" '
|
|
||||||
BEGIN { found=0 }
|
|
||||||
/^## \[/ {
|
|
||||||
if (found) exit
|
|
||||||
if ($0 ~ "\\[" ver "\\]") { found=1; next }
|
|
||||||
}
|
|
||||||
found { print }
|
|
||||||
' CHANGELOG.md | tee release_notes.md > "$FASTLANE_DIR/${VERSION_CODE}.txt"
|
|
||||||
@@ -16,15 +16,55 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.PAT_GITEA }}
|
token: ${{ secrets.PAT_GITEA }}
|
||||||
|
|
||||||
- name: Create tag if version changed
|
- name: Check version and prepare release
|
||||||
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(grep 'versionName = ' app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
|
VERSION=$(grep 'versionName = ' app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
|
||||||
echo "Current version: $VERSION"
|
VERSION_CODE=$(grep 'versionCode = ' app/build.gradle.kts | sed 's/.*versionCode = \([0-9]*\).*/\1/')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
if git tag -l | grep -q "^v${VERSION}$"; then
|
if git tag -l | grep -q "^v${VERSION}$"; then
|
||||||
echo "Tag v${VERSION} already exists, skipping"
|
echo "Tag v${VERSION} already exists, skipping"
|
||||||
|
echo "should_release=false" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
git tag "v${VERSION}"
|
echo "New version detected: v${VERSION}"
|
||||||
git push origin "v${VERSION}"
|
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||||
echo "Created and pushed tag v${VERSION}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Extract and commit fastlane changelog
|
||||||
|
if: steps.version.outputs.should_release == 'true'
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
VERSION_CODE="${{ steps.version.outputs.version_code }}"
|
||||||
|
FASTLANE_DIR="fastlane/metadata/android/en-US/changelogs"
|
||||||
|
|
||||||
|
mkdir -p "$FASTLANE_DIR"
|
||||||
|
|
||||||
|
awk -v ver="$VERSION" '
|
||||||
|
BEGIN { found=0 }
|
||||||
|
/^## \[/ {
|
||||||
|
if (found) exit
|
||||||
|
if ($0 ~ "\\[" ver "\\]") { found=1; next }
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md > "$FASTLANE_DIR/${VERSION_CODE}.txt"
|
||||||
|
|
||||||
|
git config user.name "Gitea Actions"
|
||||||
|
git config user.email "actions@gitea.local"
|
||||||
|
|
||||||
|
if git diff --quiet "$FASTLANE_DIR/${VERSION_CODE}.txt" 2>/dev/null; then
|
||||||
|
echo "No changelog changes to commit"
|
||||||
|
else
|
||||||
|
git add "$FASTLANE_DIR/${VERSION_CODE}.txt"
|
||||||
|
git commit -m "Add fastlane changelog for v${VERSION}"
|
||||||
|
git push origin main
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create and push tag
|
||||||
|
if: steps.version.outputs.should_release == 'true'
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
git tag "v${VERSION}"
|
||||||
|
git push origin "v${VERSION}"
|
||||||
|
echo "Created and pushed tag v${VERSION}"
|
||||||
|
|||||||
@@ -22,8 +22,19 @@ jobs:
|
|||||||
working-directory: .build/release
|
working-directory: .build/release
|
||||||
run: docker compose run --rm release
|
run: docker compose run --rm release
|
||||||
|
|
||||||
- name: Extract changelog
|
- name: Extract release notes
|
||||||
run: bash .build/release/extract-changelog.sh ${{ gitea.ref_name }}
|
run: |
|
||||||
|
VERSION="${{ gitea.ref_name }}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
|
||||||
|
awk -v ver="$VERSION" '
|
||||||
|
BEGIN { found=0 }
|
||||||
|
/^## \[/ {
|
||||||
|
if (found) exit
|
||||||
|
if ($0 ~ "\\[" ver "\\]") { found=1; next }
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md > release_notes.md
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
env:
|
env:
|
||||||
@@ -31,8 +42,38 @@ jobs:
|
|||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
GITEA_TOKEN: ${{ secrets.PAT_GITEA }}
|
GITEA_TOKEN: ${{ secrets.PAT_GITEA }}
|
||||||
run: |
|
run: |
|
||||||
bash .build/release/create-release.sh \
|
TAG="${{ gitea.ref_name }}"
|
||||||
"${{ gitea.ref_name }}" \
|
TITLE="ISODroid ${{ gitea.ref_name }}"
|
||||||
"ISODroid ${{ gitea.ref_name }}" \
|
NOTES_FILE="release_notes.md"
|
||||||
"release_notes.md" \
|
ASSET_PATH=".build/release/release/ISODroid-${{ gitea.ref_name }}.apk"
|
||||||
".build/release/release/ISODroid-${{ gitea.ref_name }}.apk"
|
|
||||||
|
API_URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
||||||
|
|
||||||
|
RELEASE_RESPONSE=$(curl -s -X POST "$API_URL" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"${TAG}\",
|
||||||
|
\"name\": \"${TITLE}\",
|
||||||
|
\"body\": $(jq -Rs . < "$NOTES_FILE")
|
||||||
|
}")
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
||||||
|
|
||||||
|
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Failed to create release:"
|
||||||
|
echo "$RELEASE_RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Created release with ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
ASSET_NAME=$(basename "$ASSET_PATH")
|
||||||
|
UPLOAD_URL="${API_URL}/${RELEASE_ID}/assets?name=${ASSET_NAME}"
|
||||||
|
|
||||||
|
curl -s -X POST "$UPLOAD_URL" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@${ASSET_PATH}"
|
||||||
|
|
||||||
|
echo "Uploaded asset: $ASSET_NAME"
|
||||||
|
|||||||
Reference in New Issue
Block a user