Update Submodules and Release #456
This file contains hidden or 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: Update Submodules and Release | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # 每天凌晨00:00运行 | |
| workflow_dispatch: | |
| jobs: | |
| check-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: 'recursive' | |
| - name: Check for submodule updates | |
| run: | | |
| git submodule update --progress --init --force --remote | |
| UPDATED=$(git status --porcelain) | |
| if [ -n "$UPDATED" ]; then | |
| echo "updated=true" >> $GITHUB_ENV | |
| else | |
| echo "updated=false" >> $GITHUB_ENV | |
| fi | |
| - name: Setup Node.js (latest version) | |
| if: env.updated == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'latest' | |
| - name: Install pnpm | |
| if: env.updated == 'true' | |
| uses: pnpm/[email protected] | |
| with: | |
| version: 9 | |
| - name: Update Localization | |
| if: env.updated == 'true' | |
| run: | | |
| cd GakumasPreTranslation | |
| cp .env.sample .env | |
| pnpm install | |
| pnpm ts-node main.ts | |
| - name: Get game resources | |
| if: env.updated == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: DreamGallery/Campus-adv-txts | |
| ref: main | |
| path: Campus_adv_txts | |
| - name: Copy txt to tmp | |
| if: env.updated == 'true' | |
| run: | | |
| mkdir ./raw | |
| cp -r Campus_adv_txts/Resource/adv* ./raw | |
| - name: Merge Resources | |
| if: env.updated == 'true' | |
| run: | | |
| pip install -r requirements.txt | |
| python merge.py | |
| - name: Increment version and zip files | |
| if: env.updated == 'true' | |
| run: | | |
| VERSION=$(cat version.txt | sed 's/v//') | |
| NEW_VERSION="v$(echo $VERSION | awk -F. '{ $NF++; printf "%d.%d.%d", $1, $2, $3 }')" | |
| echo "Current VERSION: $VERSION" | |
| echo "New VERSION: $NEW_VERSION" | |
| echo $NEW_VERSION > version.txt | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| zip -r GakumasTranslationData.zip local-files version.txt | |
| - name: Create Release | |
| if: env.updated == 'true' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: GakumasTranslationData.zip | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ env.NEW_VERSION }} | |
| name: ${{ env.NEW_VERSION }} | |
| body: 'New release ${{ env.NEW_VERSION }}' | |
| allowUpdates: true | |
| - name: Commit and Push Changes | |
| if: env.updated == 'true' | |
| run: | | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "GitHub Action" | |
| git add . | |
| git commit -m "Update submodules and version.txt to ${{ env.NEW_VERSION }}" | |
| git push |