diff --git a/.github/workflows/check_symlink_works.yml b/.github/workflows/check_symlink_works.yml index 3731962dd7..27db69cf74 100644 --- a/.github/workflows/check_symlink_works.yml +++ b/.github/workflows/check_symlink_works.yml @@ -16,18 +16,20 @@ concurrency: cancel-in-progress: true jobs: - test-sudo: + test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-13] + os: [ubuntu-20.04, macos-13, windows-2019] fail-fast: false steps: - uses: actions/checkout@v4 - - name: Build V - run: make -j4 - - name: Symlink - run: sudo ./v symlink + - name: Build and symlink (Windows) + if: runner.os == 'Windows' + run: ./make.bat && ./v symlink + - name: Build and symlink + if: runner.os != 'Windows' + run: make -j4 && sudo ./v symlink - name: Check if V is usable run: | pwd diff --git a/cmd/tools/vsymlink/vsymlink_windows.c.v b/cmd/tools/vsymlink/vsymlink_windows.c.v index d3f4021d5a..ffd62f347d 100644 --- a/cmd/tools/vsymlink/vsymlink_windows.c.v +++ b/cmd/tools/vsymlink/vsymlink_windows.c.v @@ -83,6 +83,20 @@ fn setup_symlink() { warn_and_exit('You might need to run this again to have the `v` command in your %PATH%') } C.RegCloseKey(reg_sys_env_handle) + if os.getenv('GITHUB_JOB') != '' { + // Append V's install location to GITHUBs PATH environment variable. + // Resources: + // 1. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files + // 2. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable + mut content := os.read_file(os.getenv('GITHUB_PATH')) or { + eprintln('The `GITHUB_PATH` env variable is not defined.') + exit(1) + } + content += '\n${new_sys_env_path}\n' + os.write_file(os.getenv('GITHUB_PATH'), content) or { + panic('Failed to write to GITHUB_PATH.') + } + } println('Done.') println('Note: Restart your shell/IDE to load the new %PATH%.') println('After restarting your shell/IDE, give `v version` a try in another directory!')