feat: enhance draft release creation with auto-generated changelog an… #21
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 with auto changelog | |
| id: create | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const tagName = context.ref.replace('refs/tags/', '') || 'v4.0'; | |
| // Use GitHub's built-in release notes generator | |
| let generatedNotes = ''; | |
| try { | |
| const { data: notes } = await github.rest.repos.generateReleaseNotes({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: tagName, | |
| }); | |
| generatedNotes = notes.body; | |
| } catch (e) { | |
| console.log('Auto-generate notes failed, using fallback:', e.message); | |
| generatedNotes = ''; | |
| } | |
| const downloads = `\n---\n\n**Downloads**\n\n| Platform | File | Architecture |\n|----------|------|--------------|\n| macOS | \`.dmg\` | Universal (Intel + Apple Silicon) |\n| Windows | \`.msi\` / \`.exe\` | x86_64 |\n| Linux | \`.deb\` / \`.AppImage\` | x86_64 |\n| Linux CLI | \`.tar.gz\` | amd64 / aarch64 |`; | |
| const body = generatedNotes | |
| ? `${generatedNotes}${downloads}` | |
| : `See the assets below to download the app for your platform.${downloads}`; | |
| const { data } = await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: tagName, | |
| name: `Fetch Github Hosts ${tagName}`, | |
| body: body, | |
| 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 | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| shell: bash | |
| run: | | |
| RAW_VERSION=${GITHUB_REF#refs/tags/v} | |
| IFS='.' read -ra parts <<< "$RAW_VERSION" | |
| VERSION="${parts[0]:-0}.${parts[1]:-0}.${parts[2]:-0}" | |
| 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 | |
| sed -i.bak 's/"version": "[^"]*"/"version": "'"$VERSION"'"/' package.json | |
| - 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 | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| RAW_VERSION=${GITHUB_REF#refs/tags/v} | |
| IFS='.' read -ra parts <<< "$RAW_VERSION" | |
| VERSION="${parts[0]:-0}.${parts[1]:-0}.${parts[2]:-0}" | |
| 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 |