fix: some reloading && folder rename #36
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 | |
| on: | |
| push: | |
| paths: | |
| - "package.json" | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from package.json | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $packageJson = Get-Content package.json | ConvertFrom-Json | |
| $version = $packageJson.version | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| Write-Host "Version: $version" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "latest" | |
| cache: "pnpm" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "src-server -> target" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build frontend | |
| run: pnpm vite:build | |
| - name: Build Rust release | |
| run: cargo build --manifest-path src-server/Cargo.toml --release | |
| - name: Create and push tag | |
| id: create_tag | |
| continue-on-error: true | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v$VERSION" -m "Release v$VERSION" || true | |
| git push origin "v$VERSION" 2>/dev/null || true | |
| - name: Create Release | |
| id: create_release | |
| if: steps.create_tag.outcome == 'success' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| release_name: Majdata Hub v${{ steps.version.outputs.version }} | |
| draft: false | |
| prerelease: false | |
| - name: Upload exe to Release | |
| if: steps.create_release.outcome == 'success' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./src-server/target/release/majdata-hub.exe | |
| asset_name: majdata-hub-v${{ steps.version.outputs.version }}.exe | |
| asset_content_type: application/octet-stream | |
| - name: Prepare artifacts for mirror | |
| if: steps.create_release.outcome == 'success' | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "temp" | |
| Copy-Item -Path "src-server/target/release/majdata-hub.exe" -Destination "temp/majdata-hub-v${{ steps.version.outputs.version }}.exe" -Force | |
| Write-Host "Prepared exe for mirror" | |
| - name: Upload to CNB mirror | |
| if: steps.create_release.outcome == 'success' | |
| shell: bash | |
| env: | |
| MIRROR_URL: ${{ vars.CNB_URL }} | |
| MIRROR_TOKEN: ${{ vars.CNB_TOKEN }} | |
| continue-on-error: true | |
| run: | | |
| cd temp | |
| git init | |
| git checkout -b main | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "Release v${{ steps.version.outputs.version }}" | |
| AUTH_URL=$(echo "$MIRROR_URL" | sed -E "s#https://#https://x-access-token:${MIRROR_TOKEN}@#") | |
| git remote remove mirror 2>/dev/null || true | |
| git remote add mirror "$AUTH_URL" | |
| git push mirror --all --force |