opt: simplify workflow

This commit is contained in:
KOWX712
2025-04-24 01:53:40 +08:00
parent 17ae54a775
commit 7fbfaf60f4

View File

@@ -82,23 +82,11 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
- name: Configure Git user
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Create a new tag
run: |
VERSION=$(grep '^version=' module/module.prop | sed 's/version=//')
git tag -a "$VERSION" -m "Release version $VERSION"
git push origin "$VERSION"
- name: Set release variables - name: Set release variables
id: set_release_variables id: set_release_variables
run: | run: |
VERSION=$(grep '^version=' module/module.prop | sed 's/version=//') VERSION=$(grep '^version=' module/module.prop | sed 's/version=//')
CURRENT_TAG="$VERSION" RELEASE_NOTES=$(awk -v tag="### $VERSION" '
RELEASE_NOTES=$(awk -v tag="### $CURRENT_TAG" '
$0 == tag {flag=1; next} $0 == tag {flag=1; next}
/^###/ && flag {exit} /^###/ && flag {exit}
flag {print} flag {print}
@@ -107,32 +95,28 @@ jobs:
if [[ "$VERSION" == *"beta"* ]]; then if [[ "$VERSION" == *"beta"* ]]; then
PRERELEASE=true PRERELEASE=true
FORMATTED_RELEASE_NOTES=$(echo -e "- Due to extensive code refactoring, you might encounter unexpected bugs in this version, feedback in [Telegram](https://t.me/kowchannel) or [create issue](https://github.com/KOWX712/Tricky-Addon-Update-Target-List/issues) if you found any issues.\n---\n### Tricky Addon module\n$RELEASE_NOTES") FORMATTED_RELEASE_NOTES=$(echo -e "- Due to extensive code refactoring, you might encounter unexpected bugs in this version, feedback in [Telegram](https://t.me/kowchannel) or [create issue](https://github.com/KOWX712/Tricky-Addon-Update-Target-List/issues) if you found any issues.\n---\n### Tricky Addon module\n$RELEASE_NOTES")
FILES="TrickyAddonModule-${VERSION}.zip"
else else
PRERELEASE=false PRERELEASE=false
FORMATTED_RELEASE_NOTES=$(echo -e "### Tricky Addon module\n$RELEASE_NOTES\n") FORMATTED_RELEASE_NOTES=$(echo -e "### Tricky Addon module\n$RELEASE_NOTES\n")
FILES="TrickyAddonModule-${VERSION}.zip"
fi fi
echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_ENV echo "CURRENT_TAG=$VERSION" >> $GITHUB_ENV
echo "ZIP_NAME=TrickyAddonModule-${VERSION}.zip" >> $GITHUB_ENV echo "ZIP_NAME=TrickyAddonModule-${VERSION}.zip" >> $GITHUB_ENV
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$FORMATTED_RELEASE_NOTES" >> $GITHUB_ENV echo "$FORMATTED_RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
echo "FILES=$FILES" >> $GITHUB_ENV
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
- name: Compress module folder - name: Compress module folder
run: | run: |
cd module && zip -r "../${{ env.ZIP_NAME }}" ./* cd module && zip -r "../${{ env.ZIP_NAME }}" ./*
echo "Created zip file: ${{ env.ZIP_NAME }}"
- name: Create release - name: Create release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
files: ${{ env.FILES }} files: ${{ env.ZIP_NAME }}
tag_name: ${{ env.CURRENT_TAG }} tag_name: ${{ env.CURRENT_TAG }}
name: ${{ env.CURRENT_TAG }} name: ${{ env.CURRENT_TAG }}
body: ${{ env.RELEASE_NOTES }} body: ${{ env.RELEASE_NOTES }}