Repository navigation
refactor: DualPurposeStorager 清理冗余代码 #3
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: Build Mod | |
| on: [push, pull_request, workflow_dispatch] | |
| permissions: | |
| contents: write | |
| jobs: | |
| buildJar: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up PATH | |
| run: | | |
| echo "${ANDROID_HOME}/build-tools/34.0.0" >> $GITHUB_PATH | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build mod jar | |
| id: build | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew deploy | |
| find build/ -name "*.jar" -ls | |
| JAR_PATH=$(find build/ -iname "silicon-*-v*.jar" 2>/dev/null | head -1) | |
| echo "jar_path=${JAR_PATH}" >> $GITHUB_OUTPUT | |
| echo "Found jar: ${JAR_PATH}" | |
| - name: Get mod version | |
| id: version | |
| run: echo "mod_version=$(grep '^version:' mod.hjson | cut -d':' -f2 | tr -d ' ')" >> $GITHUB_OUTPUT | |
| - name: Upload built jar file | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: silicon-${{ steps.version.outputs.mod_version }}-v159.7 | |
| path: ${{ steps.build.outputs.jar_path }} | |
| - name: Delete old pre-releases | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/test' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release list --repo ${{ github.repository }} --json tagName,isPrerelease \ | |
| | jq -r '.[] | select(.isPrerelease) | .tagName' \ | |
| | xargs -I {} gh release delete {} --repo ${{ github.repository }} --yes --cleanup-tag | |
| - name: Create pre-release | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/test' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "v${{ steps.version.outputs.mod_version }}" \ | |
| --repo ${{ github.repository }} \ | |
| --title "Silicon ${{ steps.version.outputs.mod_version }}" \ | |
| --prerelease \ | |
| "${{ steps.build.outputs.jar_path }}" |