Update release message #242
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- platform: android | |
os: ubuntu-latest | |
- platform: windows | |
os: windows-latest | |
arch: amd64 | |
- platform: linux | |
os: ubuntu-latest | |
arch: amd64 | |
- platform: macos | |
os: macos-13 | |
arch: amd64 | |
- platform: macos | |
os: macos-latest | |
arch: arm64 | |
steps: | |
- name: Setup Mingw64 | |
if: startsWith(matrix.platform,'windows') | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: mingw64 | |
install: mingw-w64-x86_64-gcc | |
update: true | |
- name: Set Mingw64 Env | |
if: startsWith(matrix.platform,'windows') | |
run: | | |
echo "${{ runner.temp }}\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Check Matrix | |
run: | | |
echo "Running on ${{ matrix.os }}" | |
echo "Arch: ${{ runner.arch }}" | |
gcc --version | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Get Branch | |
if: startsWith(matrix.platform,'linux') | |
run: | | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
echo "Current branch is $branch" | |
echo "BRANCH=$branch" >> $GITHUB_ENV | |
- name: Setup JAVA | |
if: startsWith(matrix.platform,'android') | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Setup NDK | |
if: startsWith(matrix.platform,'android') | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r26b | |
add-to-path: true | |
link-to-sdk: true | |
- name: Setup Android Signing | |
if: startsWith(matrix.platform,'android') | |
run: | | |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks | |
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/local.properties | |
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/local.properties | |
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/local.properties | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'core/go.mod' | |
cache-dependency-path: | | |
core/go.sum | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: 3.22.x | |
channel: 'stable' | |
cache: true | |
- name: Get Flutter Dependency | |
run: flutter pub get | |
- name: Setup | |
run: dart setup.dart ${{ matrix.platform }} ${{ matrix.arch && format('--arch {0}', matrix.arch) }} | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.platform }}${{ matrix.arch && format('-{0}', matrix.arch) }} | |
path: ./dist | |
overwrite: true | |
upload: | |
permissions: write-all | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist/ | |
pattern: artifact-* | |
merge-multiple: true | |
- name: Generate release | |
run: | | |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate)) | |
preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "") | |
version=$(echo "${{ github.ref_name }}" | sed 's/^v//') | |
sed "s|VERSION|$version|g" ./.github/release_template.md > release.md | |
currentTag="" | |
for ((i = 0; i <= ${#tags[@]}; i++)); do | |
if (( i < ${#tags[@]} )); then | |
tag=${tags[$i]} | |
else | |
tag="" | |
fi | |
if [ -n "$currentTag" ]; then | |
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then | |
break | |
fi | |
fi | |
if [ -n "$currentTag" ]; then | |
echo "## $currentTag" >> release.md | |
echo "" >> release.md | |
if [ -n "$tag" ]; then | |
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md | |
else | |
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md | |
fi | |
echo "" >> release.md | |
fi | |
currentTag=$tag | |
done | |
- name: Get Branch | |
run: | | |
branch=$(git branch --contains ${{ github.ref_name }} | grep -v "detached" | sed 's/* //') | |
echo "Current branch is $branch" | |
echo "BRANCH=$branch" >> $GITHUB_ENV | |
- name: Upload | |
if: env.BRANCH != 'main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact | |
path: ./dist | |
retention-days: 7 | |
overwrite: true | |
- name: Generate changelog | |
if: env.BRANCH == 'main' | |
run: | | |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate)) | |
preTag="" | |
currentTag="" | |
if [ -f CHANGELOG.md ]; then | |
preTag=$(grep -oP '^## \K.*' CHANGELOG.md | head -n 1) | |
fi | |
for ((i = 0; i <= ${#tags[@]}; i++)); do | |
if (( i < ${#tags[@]} )); then | |
tag=${tags[$i]} | |
else | |
tag="" | |
fi | |
if [ -n "$currentTag" ]; then | |
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then | |
break | |
fi | |
fi | |
if [ -n "$currentTag" ]; then | |
echo "## $currentTag" >> NEW_CHANGELOG.md | |
echo "" >> NEW_CHANGELOG.md | |
if [ -n "$tag" ]; then | |
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md | |
else | |
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md | |
fi | |
echo "" >> NEW_CHANGELOG.md | |
fi | |
currentTag=$tag | |
done | |
if [ -f CHANGELOG.md ]; then | |
cat CHANGELOG.md >> NEW_CHANGELOG.md | |
fi | |
mv NEW_CHANGELOG.md CHANGELOG.md | |
- name: Commit | |
run: | | |
git config --local user.email "chen08209@gmail.com" | |
git config --local user.name "chen08209" | |
git add CHANGELOG.md | |
if ! git diff --cached --quiet; then | |
git commit -m "Update changelog" | |
git push | |
else | |
echo "CHANGELOG.md not changed" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release | |
if: env.BRANCH == 'main' | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./dist/* | |
body_path: './release.md' | |
- name: Create Fdroid Source Dir | |
if: env.BRANCH == 'main' | |
run: | | |
mkdir -p ./tmp | |
cp ./dist/*android-arm64-v8a* ./tmp/ || true | |
echo "Files copied successfully" | |
- name: Push to fdroid repo | |
if: env.BRANCH == 'main' | |
uses: cpina/github-action-push-to-another-repository@v1.7.2 | |
env: | |
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
with: | |
source-directory: ./tmp/ | |
destination-github-username: chen08209 | |
destination-repository-name: FlClash-fdroid-repo | |
user-name: 'github-actions[bot]' | |
user-email: 'github-actions[bot]@users.noreply.github.com' | |
target-branch: action-pr | |
commit-message: Update from ${{ github.ref_name }} | |
target-directory: /tmp/ |