-
-
Notifications
You must be signed in to change notification settings - Fork 149
94 lines (80 loc) · 3.67 KB
/
Copy pathprepare-release.yml
File metadata and controls
94 lines (80 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Prepare Release
on:
workflow_dispatch:
jobs:
prepare-release:
name: Update Metadata and Tag
runs-on: ubuntu-latest
steps:
- name: Generate Bot Token
id: generate-token
uses: actions/create-github-app-token@v3.1.1
with:
app-id: ${{ secrets.FLADDER_BOT_APP_ID }}
private-key: ${{ secrets.FLADDER_BOT_APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4.1.1
with:
ref: develop
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Extract Version
id: version
run: |
# Extract version from pubspec.yaml (e.g., 0.10.3+1)
FULL_VERSION=$(grep '^version: ' pubspec.yaml | sed 's/version: //')
# Remove build number (e.g., 0.10.3)
VERSION_NAME=$(echo "$FULL_VERSION" | cut -d'+' -f1)
# Exact Build Number (e.g., 1)
BUILD_NUMBER=$(echo "$FULL_VERSION" | cut -d'+' -f2)
echo "version=${VERSION_NAME}" >> "$GITHUB_OUTPUT"
echo "build_number=${BUILD_NUMBER}" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION_NAME (Build: $BUILD_NUMBER)"
# Check if this version is already tagged
if git rev-parse "v${VERSION_NAME}" >/dev/null 2>&1; then
echo "is_new_version=false" >> "$GITHUB_OUTPUT"
echo "Status: Version is already tagged."
else
echo "is_new_version=true" >> "$GITHUB_OUTPUT"
echo "Status: New version detected."
fi
- name: Update metainfo.xml
if: steps.version.outputs.is_new_version == 'true'
env:
CHANGELOG_MSG: "See the full changelog at: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}"
run: |
VERSION="${{ steps.version.outputs.version }}"
DATE=$(date +%Y-%m-%d)
NEW_RELEASE=" <releases>\n <release version=\"${VERSION}\" date=\"${DATE}\">\n <description>\n <p>${{ env.CHANGELOG_MSG }}</p>\n </description>\n </release>\n </releases>"
perl -i -0777 -pe "s@ <releases>.*?</releases>@$NEW_RELEASE@s" flatpak/nl.jknaapen.fladder.metainfo.xml
- name: Update Fastlane Changelog
if: steps.version.outputs.is_new_version == 'true'
env:
CHANGELOG_MSG: "See the full changelog at: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}"
run: |
VERSION="${{ steps.version.outputs.version }}"
mkdir -p fastlane/metadata/android/en-US/changelogs
printf '%s' "${{ env.CHANGELOG_MSG }}" > "fastlane/metadata/android/en-US/changelogs/${VERSION}.txt"
- name: Commit, Merge and Tag
if: steps.version.outputs.is_new_version == 'true'
run: |
git config user.name "Fladder Bot"
git config user.email "fladder-bot[bot]@users.noreply.github.com"
VERSION="v${{ steps.version.outputs.version }}"
# 1. Commit metadata to develop
git add flatpak/nl.jknaapen.fladder.metainfo.xml
git add fastlane/metadata/android/en-US/changelogs/
if git diff --staged --quiet; then
echo "No changes to metadata"
else
git commit -m "chore: prepare release $VERSION"
git push origin develop
fi
# 2. Merge develop into main
git fetch origin main
git checkout main
git merge develop --no-ff -m "chore: merge develop into main for $VERSION"
git push origin main
# 3. Create and push the tag on main
git tag "$VERSION"
git push origin "$VERSION"