feat: inject version from tag into application and update version dis… #18
Workflow file for this run
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: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| env: | |
| APP_NAME: fetch-github-hosts | |
| jobs: | |
| create-release: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_id: ${{ steps.create.outputs.result }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create draft release | |
| id: create | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const tagName = context.ref.replace('refs/tags/', '') || 'v4.0'; | |
| const { data } = await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: tagName, | |
| name: `Fetch Github Hosts ${tagName}`, | |
| body: `See the assets below to download the app for your platform.\n\n**macOS**: \`.dmg\` (Universal binary - supports both Intel & Apple Silicon)\n**Windows**: \`.msi\` / \`.exe\`\n**Linux**: \`.deb\` / \`.AppImage\`\n**Linux Standalone Binary**: \`.tar.gz\` (amd64 / aarch64, no installation needed)`, | |
| draft: true, | |
| prerelease: false | |
| }); | |
| return data.id; | |
| result-encoding: string | |
| build-tauri: | |
| needs: create-release | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # macOS - Universal binary (Intel + Apple Silicon) | |
| - platform: macos-latest | |
| args: --target universal-apple-darwin | |
| rust_targets: aarch64-apple-darwin,x86_64-apple-darwin | |
| name: macos-universal | |
| # Linux x86_64 | |
| - platform: ubuntu-22.04 | |
| args: '' | |
| rust_targets: '' | |
| name: linux-x86_64 | |
| # Windows | |
| - platform: windows-latest | |
| args: '' | |
| rust_targets: '' | |
| name: windows-x86_64 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| cache: 'npm' | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.rust_targets }} | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './src-tauri -> target' | |
| - name: Install system dependencies (Linux) | |
| if: contains(matrix.name, 'linux') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libwebkit2gtk-4.1-dev \ | |
| libappindicator3-dev \ | |
| librsvg2-dev \ | |
| patchelf \ | |
| pkg-config \ | |
| libglib2.0-dev \ | |
| libgtk-3-dev \ | |
| libgdk-pixbuf2.0-dev \ | |
| libpango1.0-dev \ | |
| libatk1.0-dev \ | |
| libcairo-gobject2 \ | |
| libjavascriptcoregtk-4.1-dev | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| - name: Inject version from tag | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Injecting version: $VERSION" | |
| sed -i.bak "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" src-tauri/tauri.conf.json | |
| sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml | |
| - name: Build static frontend | |
| run: npx cross-env NUXT_CLI_WRAPPER=false npx nuxt generate | |
| - name: Build Tauri app | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| releaseId: ${{ needs.create-release.outputs.release_id }} | |
| args: ${{ matrix.args }} | |
| build-cli: | |
| needs: create-release | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: ubuntu-22.04 | |
| target: x86_64-unknown-linux-musl | |
| arch: amd64 | |
| - platform: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-musl | |
| arch: aarch64 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install musl tools | |
| run: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './src-tauri -> target' | |
| - name: Inject version from tag | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Injecting version: $VERSION" | |
| sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml | |
| - name: Build CLI binary (fully static, no system dependencies) | |
| working-directory: src-tauri | |
| run: cargo build --release --no-default-features --target ${{ matrix.target }} | |
| - name: Package standalone binary | |
| run: | | |
| TAR_NAME="fetch-github-hosts_linux_${{ matrix.arch }}.tar.gz" | |
| tar -czf "$TAR_NAME" -C "src-tauri/target/${{ matrix.target }}/release" "fetch-github-hosts" | |
| echo "TAR_NAME=$TAR_NAME" >> "$GITHUB_ENV" | |
| - name: Upload standalone binary | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| gh release upload "$TAG_NAME" "$TAR_NAME" --repo "${{ github.repository }}" --clobber |