Merge branch 'dev' #97
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: Release | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| - '**.spec.js' | |
| - '.idea' | |
| - '.gitignore' | |
| - '.github/**' | |
| - '!.github/workflows/release.yml' | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: 'bash' | |
| env: | |
| NODE_NO_WARNINGS: 1 | |
| npm_config_audit: false | |
| npm_config_fund: false | |
| jobs: | |
| draft: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release-note: ${{ steps.release-note.outputs.release-note }} | |
| version: ${{ steps.version.outputs.build-version }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Get last git tag | |
| id: tag | |
| run: echo "last-tag=$(git describe --tags --abbrev=0 || git rev-list --max-parents=0 ${{github.ref}})" >> $GITHUB_OUTPUT | |
| - name: Generate release notes | |
| id: release-note | |
| run: | | |
| RELEASE_NOTES=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline) | |
| RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}" | |
| RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}" | |
| RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}" | |
| echo "release-note=$RELEASE_NOTES" >> $GITHUB_OUTPUT | |
| - name: Get version from current date | |
| id: version | |
| run: | | |
| VERSION=$(node -e "console.log(require('./package.json').version)") | |
| echo "build-version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Delete outdated drafts | |
| uses: hugo19941994/delete-draft-releases@v1.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Release Draft | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| prerelease: true | |
| draft: true | |
| tag_name: v${{ steps.version.outputs.build-version }} | |
| name: v${{ steps.version.outputs.build-version }} | |
| body: "Release v${{ steps.version.outputs.build-version }}" | |
| upload_artifacts: | |
| needs: [draft] | |
| if: ${{ !contains(github.event.head_commit.message, '[skip]') }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| # The easiest way to transfer release notes to a compiled application is create `release-notes.md` in the build resources. | |
| # See https://github.com/electron-userland/electron-builder/issues/1511#issuecomment-310160119 | |
| - name: Create build resources directory | |
| run: mkdir -p resources | |
| - name: Prepare release notes | |
| env: | |
| RELEASE_NOTE: ${{ needs.draft.outputs.release-note }} | |
| run: echo "$RELEASE_NOTE" >> ./resources/release-notes.md | |
| # If building a release for macos, need to do notarization. | |
| # - name: Prepare for app notarization | |
| # if: startsWith(matrix.os, 'macos') | |
| # # Import Apple API key for app notarization on macOS | |
| # run: | | |
| # mkdir -p ~/private_keys/ | |
| # echo '${{ secrets.apple_api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8 | |
| # If releasing Linux app to Snapcraft, install and sign in. | |
| # - name: Install Snapcraft | |
| # uses: samuelmeuli/action-snapcraft@v1 | |
| # # Only install Snapcraft on Ubuntu | |
| # if: startsWith(matrix.os, 'ubuntu') | |
| # with: | |
| # # Log in to Snap Store | |
| # snapcraft_token: ${{ secrets.snapcraft_token }} | |
| # Compile app and upload artifacts | |
| - name: Compile & release Electron app | |
| uses: samuelmeuli/action-electron-builder@v1 | |
| env: | |
| # AWS Credentials for S3 publishing | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: ${{ secrets.AWS_REGION }} # Use the region secret | |
| # GitHub Token for creating GitHub releases (if still needed) | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VITE_APP_VERSION: ${{ needs.draft.outputs.version }} | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| build_script_name: build | |
| args: --config electron-builder.yml --publish always # Ensure publishing is triggered | |
| # release: true # Set to false if you ONLY want to publish to S3 and not create a GitHub Release artifact | |
| max_attempts: 3 | |
| build_web: | |
| needs: [draft] | |
| runs-on: ubuntu-latest | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build web target | |
| run: npm run build:web | |
| - name: Create Web App Zip Archive | |
| run: | | |
| cd ./dist/web | |
| zip -r ../../open-llm-vtuber-web-${{ needs.draft.outputs.version }}.zip . | |
| cd ../.. # Go back to the workspace root | |
| - name: Upload Web App Zip to S3 | |
| run: | | |
| aws s3 cp ./open-llm-vtuber-web-${{ needs.draft.outputs.version }}.zip s3://open-llm-vtuber-frontend/open-llm-vtuber-web-${{ needs.draft.outputs.version }}.zip | |
| echo "Web app zip uploaded. Public access depends on S3 bucket policy/settings." | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Upload web build to S3 | |
| run: | | |
| aws s3 sync ./dist/web s3://open-llm-vtuber-frontend/web --delete | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: build | |
| folder: dist/web | |
| clean: true | |
| single-commit: true | |
| token: ${{ secrets.GITHUB_TOKEN }} |