update ci #112
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- README.md | |
- README_CN.md | |
pull_request: | |
paths-ignore: | |
- README.md | |
- README_CN.md | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: 'pages' | |
cancel-in-progress: true | |
jobs: | |
build-web: | |
name: Build Web | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
env: | |
ONEDRIVE_AUTH: ${{ secrets.ONEDRIVE_AUTH }} | |
ONEDRIVE_GME: ${{ secrets.ONEDRIVE_GME }} | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
REDIRECT_URI: ${{ secrets.REDIRECT_URI }} | |
run: npm run build | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: './dist' | |
deploy: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: | |
- build-web | |
steps: | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v3 | |
build-android: | |
name: Build Android | |
runs-on: ubuntu-latest | |
env: | |
KEYSTORE: ${{ secrets.KEYSTORE }} | |
if: github.env.KEYSTORE != '' | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Decode and save keystore | |
run: | | |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks | |
- name: Save key.properties | |
run: | | |
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
echo "storeFile=keystore.jks" >> android/key.properties | |
- name: Grant execute permission for gradlew | |
run: chmod +x android/gradlew | |
- name: Build release apk | |
run: cd android && ./gradlew assembleRelease | |
- name: Rename APK | |
run: mv android/app/build/outputs/apk/release/app-release.apk OMP_android.apk | |
- name: Upload Android artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OMP_android | |
path: OMP_android.apk | |
release: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: | |
- build-web | |
- build-android | |
- deploy | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get version | |
id: yq | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.version' package.json | |
- name: Print version | |
run: echo ${{ steps.yq.outputs.result }} | |
- name: Prepare tag name | |
id: tag_name | |
run: | | |
VERSION="${{ steps.yq.outputs.result }}" | |
TAG_NAME="v${VERSION}" | |
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_OUTPUT" | |
- name: Check tag | |
uses: mukunku/[email protected] | |
id: check-tag | |
with: | |
tag: ${{ steps.tag_name.outputs.TAG_NAME }} | |
- name: Eextract log | |
if: steps.check-tag.outputs.exists == 'false' | |
run: python extract_log.py ${{ steps.tag_name.outputs.TAG_NAME }} | |
- name: Download Android artifact | |
if: steps.check-tag.outputs.exists == 'false' | |
uses: actions/download-artifact@v4 | |
with: | |
name: OMP_android | |
path: artifacts | |
- name: Release | |
if: steps.check-tag.outputs.exists == 'false' | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }} | |
body_path: CHANGELOG_${{ steps.tag_name.outputs.TAG_NAME }}.md | |
draft: false | |
prerelease: false | |
files: | | |
artifacts/OMP_android.apk |