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 React App with GitHub Pages | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build app | |
| run: npm run build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v2 | |
| with: | |
| name: github-pages | |
| path: ./build | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: github-pages | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| build-electron-win: | |
| needs: deploy | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| platform: [win] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Install Wine | |
| run: | | |
| sudo dpkg --add-architecture i386 | |
| sudo apt update | |
| sudo apt install -y wine64 wine32 | |
| - name: Build | |
| run: npm run build | |
| - name: Build Electron App | |
| run: | | |
| case ${{ matrix.platform }} in | |
| win) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --win;; | |
| mac) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --mac ;; | |
| linux) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --linux AppImage ;; | |
| esac | |
| - name: Archive Build Outputs | |
| run: | | |
| mkdir -p artifacts | |
| case ${{ matrix.platform }} in | |
| win) mv dist/*.exe artifacts/ ;; | |
| mac) mv dist/*.dmg artifacts/ ;; | |
| linux) mv dist/*.AppImage artifacts/ ;; | |
| esac | |
| - name: Upload Build Outputs | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: ${{ matrix.platform }}-builds | |
| path: artifacts | |
| - name: Extract version from package.json | |
| id: extract_version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "Version extracted: $VERSION" | |
| echo "::set-output name=version::$VERSION" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| build-tauri-win: | |
| needs: deploy | |
| runs-on: windows-latest | |
| steps: | |
| # Step 1: Checkout Code | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # Step 2: Set up Rust | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| profile: minimal | |
| components: rustfmt, clippy, llvm-tools | |
| # Step 3: Install dependencies | |
| - name: Install Chocolatey and Tauri CLI | |
| run: | | |
| choco install -y nsis | |
| cargo install tauri-cli | |
| # Step 4: Install and build | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build-win | |
| - name: Build the application | |
| run: | | |
| cd src-tauri | |
| cargo build --release | |
| cd .. | |
| - name: Install Tauri dependencies | |
| run: | | |
| # Install dependencies for building Tauri apps | |
| cargo install tauri-cli | |
| # Step 4: Build Tauri App | |
| - name: Build Tauri App | |
| run: cargo tauri build | |
| # List the contents of the bundle directories to see what was generated | |
| - name: List Bundle Artifacts | |
| run: | | |
| echo "Listing all files in the msi bundle directory:" | |
| ls -la src-tauri/target/release/bundle/msi || echo "No msi directory found." | |
| echo "Listing all files in the nsis bundle directory:" | |
| ls -la src-tauri/target/release/bundle/nsis || echo "No nsis directory found." | |
| # Step 5: Archive Build Artifacts | |
| - name: Archive artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-windows-msi | |
| path: src-tauri/target/release/bundle/msi/* | |
| - name: Archive artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-windows-nsis | |
| path: src-tauri/target/release/bundle/nsis/* | |
| build-tauri-linux: | |
| needs: deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout Code | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # Step 2: Set up Rust | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| profile: minimal | |
| components: rustfmt, clippy, llvm-tools # Added llvm-tools as an example | |
| - name: Install GDK and dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libgtk-3-dev \ | |
| libsoup-3.0-dev \ | |
| libjavascriptcoregtk-4.1-dev \ | |
| libtasn1-dev \ | |
| libwebkit2gtk-4.1-dev | |
| - name: Set PKG_CONFIG_PATH | |
| run: | | |
| export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig" # Adjust this path if necessary | |
| echo "PKG_CONFIG_PATH set to $PKG_CONFIG_PATH" | |
| # Step 3: Install and build | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| - name: Build the application | |
| run: | | |
| cd src-tauri | |
| cargo build --release | |
| cd .. | |
| - name: Install Tauri dependencies | |
| run: | | |
| # Install dependencies for building Tauri apps | |
| cargo install tauri-cli | |
| # Step 4: Build Tauri App | |
| - name: Build Tauri App | |
| run: cargo tauri build | |
| # List the contents of the bundle directories to see what was generated | |
| - name: List Bundle Artifacts | |
| run: | | |
| echo "Listing all files in the DEB bundle directory:" | |
| ls -la src-tauri/target/release/bundle/deb || echo "No DEB directory found." | |
| echo "Listing all files in the RPM bundle directory:" | |
| ls -la src-tauri/target/release/bundle/rpm || echo "No RPM directory found." | |
| echo "Listing all files in the AppImage bundle directory:" | |
| ls -la src-tauri/target/release/bundle/appimage || echo "No AppImage directory found." | |
| # Step 5: Archive Build Artifacts | |
| - name: Archive artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-linux-deb | |
| path: /src-tauri/target/release/bundle/deb/* | |
| - name: Archive artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-linux-rpm | |
| path: /src-tauri/target/release/bundle/rpm/* | |
| - name: Archive artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: app-linux-appimage | |
| path: /src-tauri/target/release/bundle/appimage/* | |
| build-electron: | |
| needs: build-electron-win | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| platform: [mac, linux] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| - name: Build Electron App | |
| run: | | |
| case ${{ matrix.platform }} in | |
| win) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --win;; | |
| mac) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --mac ;; | |
| linux) GH_TOKEN=${{ secrets.GITHUB_TOKEN }} npm run dist -- --linux AppImage ;; | |
| esac | |
| - name: Archive Build Outputs | |
| run: | | |
| mkdir -p artifacts | |
| case ${{ matrix.platform }} in | |
| win) mv dist/*.exe artifacts/ ;; | |
| mac) mv dist/*.dmg artifacts/ ;; | |
| linux) mv dist/*.AppImage artifacts/ ;; | |
| esac | |
| - name: Upload Build Outputs | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: ${{ matrix.platform }}-builds | |
| path: artifacts | |
| release: | |
| needs: [build-electron, build-tauri-win, build-tauri-linux] | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Electron | |
| - name: Download win Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: win-builds | |
| - name: Download mac Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: mac-builds | |
| - name: Download linux Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: linux-builds | |
| # Tauri | |
| - name: Download Tauri Windows Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: app-windows-msi | |
| - name: Download Tauri Windows Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: app-windows-nsis | |
| # Linux | |
| - name: Download Tauri Linux Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: app-linux-deb | |
| - name: Download Tauri Linux Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: app-linux-rpm | |
| - name: Download Tauri Linux Artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: app-linux-appimage | |
| # Create a new GitHub release | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VERSION: ${{ env.VERSION }} | |
| with: | |
| tag_name: ${{ github.ref_name }}-${{ github.run_id }} | |
| release_name: Release New Version ${{ env.VERSION }} | |
| draft: false | |
| prerelease: false | |
| - name: Find All Files Matching VERSION | |
| id: find_files | |
| run: | | |
| VERSION=${{ env.VERSION }} | |
| files=($(ls ./*${VERSION}* 2>/dev/null || echo "")) | |
| if [ ${#files[@]} -eq 0 ]; then | |
| echo "Error: No files found matching VERSION ${VERSION}" | |
| exit 1 | |
| fi | |
| echo "Found files: ${files[@]}" | |
| file_list=$(IFS=','; echo "${files[*]}") | |
| echo "file_list=$file_list" >> $GITHUB_ENV | |
| - name: Upload Release Assets | |
| run: | | |
| IFS=',' read -r -a file_array <<< "${{ env.file_list }}" | |
| for file in "${file_array[@]}"; do | |
| echo "Uploading $file..." | |
| response=$(curl -XPOST \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: application/octet-stream" \ | |
| --data-binary @$file \ | |
| "https://uploads.github.com/repos/iDataVisualizationLab/TxDOT/releases/${{ steps.create_release.outputs.id }}/assets?name=$(basename $file)" \ | |
| -w "%{http_code}" -o /dev/null) | |
| if [ "$response" -ne 201 ]; then | |
| echo "Error uploading $file: HTTP status $response" | |
| else | |
| echo "$file uploaded successfully." | |
| fi | |
| done | |
| env: | |
| file_list: ${{ env.file_list }} | |