Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for self-hosted windows runners #45

Open
dceddia opened this issue Sep 27, 2024 · 2 comments
Open

Add support for self-hosted windows runners #45

dceddia opened this issue Sep 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dceddia
Copy link

dceddia commented Sep 27, 2024

I'm building a Tauri app on a self-hosted Windows runner. Here's the relevant bit of the action yaml:

name: 'publish'

on:
  push:
    branches:
      - release

jobs:
  publish-tauri:
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'macos-latest' # for Arm and Intel based macs
            args: '--target universal-apple-darwin'
          - platform: 'windows-latest'
            args: ''
          #- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
          #  args: ''

    runs-on: [self-hosted, "${{ matrix.platform }}"]
    steps:
      - uses: actions/checkout@v4

      # ... sets up node and stuff here ...

      - name: install Rust stable
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
          targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

      - name: Rust cache
        uses: swatinem/rust-cache@v2
        with:
          workspaces: './src-tauri -> target'

The output from the action looks like:

Warning: Unexpected input(s) 'targets', valid inputs are ['toolchain', 'target', 'components', 'cache', 'cache-workspaces', 'cache-directories', 'cache-on-failure', 'cache-key', 'matcher', 'rustflags', 'override']
Run actions-rust-lang/setup-rust-toolchain@v1
  with:
    cache: true
    cache-on-failure: true
    matcher: true
    rustflags: -D warnings
    override: true
  env:
    PNPM_HOME: C:\Windows\ServiceProfiles\NetworkService\setup-pnpm\node_modules\.bin
Run : construct rustup command line
  : construct rustup command line
  echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
  echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
  echo "downgrade=" >> $GITHUB_OUTPUT
  Error: bash: command not found

It looks like this repo's action.yml handles Windows in a couple spots but maybe not all, and I think the Github-hosted runners do actually have bash installed so this works fine there.

I'd also be fine with adding a step to install bash if that seems better, though the answer here makes that sound like it might not be the right path.

@jonasbb
Copy link
Member

jonasbb commented Sep 27, 2024

In the current state the action mainly targets the official GitHub runners. I am happy to accept PRs to expand the support here, but I have no way to test it. Besides installing bash, you also have to figure out how to install rustup. There is some support for installing rustup (

- name: Install rustup, if needed
if: runner.os != 'Windows'
shell: bash
run: |
if ! command -v rustup &> /dev/null ; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
fi
), which comes from dtolnay/rust-toolchain#8 but excludes windows.

The requirements could be better documented. A bash that is not ancient and currently an installed version of rustup. With the rustup installation fixed/updated this might be traded with curl support.

@jonasbb jonasbb added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 27, 2024
@dceddia
Copy link
Author

dceddia commented Sep 28, 2024

Ahh yep ok that makes sense.

I was hoping to set up the Github Action such that it would be able to bootstrap an otherwise clean Windows install into a build machine, but that seems pretty difficult to pull off.

I ended up installing git (which came with bash) and rustup (which first required an install of Visual Studio via a GUI installer) and for my use case I also need signtool and a vendor-specific tool for accessing a hardware signing token. So I think I'm just going to accept that this needs some manual setup, and leave myself a trail of documentation.

@jonasbb jonasbb changed the title Failing with "bash: command not found" on self-hosted Windows runner Add support for self-hosted windows runners Oct 21, 2024
@jonasbb jonasbb removed the documentation Improvements or additions to documentation label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants
@jonasbb @dceddia and others