Skip to content

Commit

Permalink
ci(github): update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Oct 15, 2024
1 parent 98c3164 commit 142a388
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 125 deletions.
200 changes: 109 additions & 91 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,114 +21,132 @@ on:

jobs:
build:
name: Build
runs-on: windows-latest
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
strategy:
fail-fast: false
fail-fast: true
matrix:
target:
- x86_64-pc-windows-msvc
platform:
- os-name: Windows-x86_64
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- os-name: Windows-aarch64
runs-on: windows-latest
target: aarch64-pc-windows-msvc
runs-on: ${{ matrix.platform.runs-on }}
permissions: write-all
env:
RUSTFLAGS: -Ctarget-feature=+crt-static -Dwarnings
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prep cargo dirs
run: |
New-Item "${env:USERPROFILE}\.cargo\registry" -ItemType Directory -Force
New-Item "${env:USERPROFILE}\.cargo\git" -ItemType Directory -Force
shell: powershell

- name: Set environment variables appropriately for the build
run: |
echo "%USERPROFILE%\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
echo "TARGET=${{ matrix.target }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
echo "SKIP_TESTS=" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Cache cargo registry, git trees and binaries
uses: actions/cache@v3
- run: rustup toolchain install stable --profile minimal
- run: rustup toolchain install nightly --allow-downgrade -c rustfmt
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Get rustc commit hash
id: cargo-target-cache
run: |
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
shell: bash

- name: Cache cargo build
uses: actions/cache@v3
cache-on-failure: "true"
cache-all-crates: "true"
- run: cargo +nightly fmt --check
- run: cargo clippy
- uses: houseabsolute/actions-rust-cross@v0
with:
path: target
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install Rustup using win.rustup.rs
run: |
# Disable the download progress bar which can cause perf issues
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --profile=minimal
shell: powershell

- name: Ensure stable toolchain is up to date
run: rustup update stable
shell: bash

- name: Install the target
run: |
rustup target install ${{ matrix.target }}
- name: Run a full build
run: |
cargo build --locked --release --target ${{ matrix.target }}
- name: Create MSI installer
run: |
command: "build"
target: ${{ matrix.platform.target }}
args: "--locked --release"
- run: |
cargo install cargo-wix
cargo wix --nocapture --target ${{ matrix.target }}
- name: Upload the built artifacts
uses: actions/upload-artifact@v3
cargo wix --no-build --nocapture --target ${{ matrix.platform.target }}
- uses: actions/upload-artifact@v4
with:
name: whkd-${{ matrix.target }}
name: whkd-${{ matrix.platform.target }}-${{ github.sha }}
path: |
target/${{ matrix.target }}/release/whkd.exe
target/${{ matrix.target }}/release/whkd.pdb
target/${{ matrix.platform.target }}/release/*.exe
target/${{ matrix.platform.target }}/release/*.pdb
target/wix/whkd-*.msi
retention-days: 7
retention-days: 14

# Release
- name: Generate changelog
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
release-dry-run:
needs: build
runs-on: windows-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- shell: bash
run: |
TAG=${{ github.ref_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
- shell: bash
run: ls -R
- run: |
Compress-Archive ./whkd-x86-64-pc-windows-msvc-${{ github.sha }}/x86-64-pc-windows-msvc/release/*.exe whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip
Copy-Item ./whkd-x86-64-pc-windows-msvc-${{ github.sha }}/wix/*x86_64.msi -Destination ./whkd-$Env:VERSION-x86_64.msi
echo "$((Get-FileHash whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip).Hash.ToLower()) whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip" >checksums.txt
Compress-Archive ./whkd-aarch64-pc-windows-msvc-${{ github.sha }}/aarch64-pc-windows-msvc/release/*.exe whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip
Copy-Item ./whkd-aarch64-pc-windows-msvc-${{ github.sha }}/wix/*x86_64.msi -Destination ./whkd-$Env:VERSION-x86_64.msi
echo "$((Get-FileHash whkd-$Env:VERSION-aarch64-pc-windows-msvc.zip).Hash.ToLower()) whkd-$Env:VERSION-aarch64-pc-windows-msvc.zip" >>checksums.txt
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
cache-all-crates: "true"
- shell: bash
run: |
if ! type kokai >/dev/null; then cargo install --locked kokai --force; fi
git tag -d nightly
kokai release --no-emoji --add-links github:commits,issues --ref "$(git tag --points-at HEAD)" >"CHANGELOG.md"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
if: startsWith(github.ref, 'refs/tags/v')
- uses: softprops/action-gh-release@v2
with:
version: latest
args: release --skip-validate --rm-dist --release-notes=CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add MSI to release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
body_path: "CHANGELOG.md"
draft: true
files: |
checksums.txt
*.zip
*.msi
release:
needs: build
runs-on: windows-latest
permissions: write-all
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
with:
files: "target/wix/whkd-*.msi"

- name: Publish to WinGet
if: startsWith(github.ref, 'refs/tags/v')
fetch-depth: 0
- shell: bash
run: |
TAG=${{ github.ref_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
- run: |
Compress-Archive ./whkd-x86-64-pc-windows-msvc-${{ github.sha }}/x86-64-pc-windows-msvc/release/*.exe whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip
Copy-Item ./whkd-x86-64-pc-windows-msvc-${{ github.sha }}/wix/*x86_64.msi -Destination ./whkd-$Env:VERSION-x86_64.msi
echo "$((Get-FileHash whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip).Hash.ToLower()) whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip" >checksums.txt
Compress-Archive ./whkd-aarch64-pc-windows-msvc-${{ github.sha }}/aarch64-pc-windows-msvc/release/*.exe whkd-$Env:VERSION-x86_64-pc-windows-msvc.zip
Copy-Item ./whkd-aarch64-pc-windows-msvc-${{ github.sha }}/wix/*x86_64.msi -Destination ./whkd-$Env:VERSION-x86_64.msi
echo "$((Get-FileHash whkd-$Env:VERSION-aarch64-pc-windows-msvc.zip).Hash.ToLower()) whkd-$Env:VERSION-aarch64-pc-windows-msvc.zip" >>checksums.txt
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
cache-all-crates: "true"
- shell: bash
run: |
if ! type kokai >/dev/null; then cargo install --locked kokai --force; fi
git tag -d nightly
kokai release --no-emoji --add-links github:commits,issues --ref "$(git tag --points-at HEAD)" >"CHANGELOG.md"
- uses: softprops/action-gh-release@v2
with:
body_path: "CHANGELOG.md"
files: |
checksums.txt
*.zip
*.msi
- if: startsWith(github.ref, 'refs/tags/v')
uses: vedantmgoyal2009/winget-releaser@v2
with:
identifier: LGUG2Z.whkd
Expand Down
32 changes: 0 additions & 32 deletions .goreleaser.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ alt + h : echo "Hello""#;

assert_eq!(output.unwrap(), expected);
}

#[test]
fn test_parse() {
let src = r#"
Expand Down
2 changes: 1 addition & 1 deletion wix/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
Keywords='Installer'
Description='A simple hotkey daemon for Windows'
Manufacturer='Jade Iqbal'
InstallerVersion='450'
InstallerVersion='500'
Languages='1033'
Compressed='yes'
InstallScope='perMachine'
Expand Down

0 comments on commit 142a388

Please sign in to comment.