Skip to content

Commit

Permalink
ci: Set BINSTALL_VERSION in install script tests
Browse files Browse the repository at this point in the history
When running the install-script workflow in Github Actions, add matrix
options for not setting the variable, setting it to the latest release
with the `v` prefix, and setting it to the latest release without the
`v` prefix.
  • Loading branch information
mjpieters committed Nov 19, 2024
1 parent 5385535 commit 8111fa2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/install-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
matrix:
os: [macos-latest, ubuntu-latest]
set_cargo_home: [t, f]
set_binstall_version: ['no', 'with-v', 'without-v']

runs-on: ${{ matrix.os }}

Expand All @@ -44,6 +45,18 @@ jobs:
mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
- name: Set `BINSTALL_VERSION`
if: matrix.set_binstall_version != 'no'
env:
STRIP_V: ${{ matrix.set_cargo_home == 'with-v' && '1' || '' }}
GH_TOKEN: ${{ github.token }}
run: |
# fetch most recent release tag.
BINSTALL_VERSION="$(gh release list --json name --jq '[.[] | select(.name | startswith("v")) | .name] | first')"
if [[ -n $STRIP_V ]]; then BINSTALL_VERSION="${BINSTALL_VERSION#v*}"; fi
echo "Setting BINSTALL_VERSION=$BINSTALL_VERSION"
echo "BINSTALL_VERSION=$BINSTALL_VERSION" >> "$GITHUB_ENV"
- name: Install `cargo-binstall` using scripts
run: ./install-from-binstall-release.sh
env:
Expand All @@ -59,6 +72,7 @@ jobs:
fail-fast: false
matrix:
set_cargo_home: [t, f]
set_binstall_version: ['no', 'with-v', 'without-v']

runs-on: windows-latest

Expand All @@ -73,6 +87,18 @@ jobs:
mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
- name: Set `BINSTALL_VERSION`
if: matrix.set_binstall_version != 'no'
env:
GH_TOKEN: ${{ github.token }}
STRIP_V: ${{ matrix.set_cargo_home == 'with-v' && '1' || '' }}
run: |
# fetch most recent release name.
BINSTALL_VERSION="$(gh release list --json name --jq '[.[] | select(.name | startswith("v")) | .name] | first')"
if [[ -n $STRIP_V ]]; then BINSTALL_VERSION="${BINSTALL_VERSION#v*}"; fi
echo "Setting BINSTALL_VERSION=$BINSTALL_VERSION"
echo "BINSTALL_VERSION=$BINSTALL_VERSION" >> "$GITHUB_ENV"
- name: Install `cargo-binstall` using scripts
run: ./install-from-binstall-release.ps1
env:
Expand All @@ -86,6 +112,7 @@ jobs:
fail-fast: false
matrix:
set_cargo_home: [t, f]
set_binstall_version: ['no', 'with-v', 'without-v']

runs-on: windows-latest

Expand All @@ -100,6 +127,18 @@ jobs:
mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
- name: Set `BINSTALL_VERSION`
if: matrix.set_binstall_version != 'no'
env:
GH_TOKEN: ${{ github.token }}
STRIP_V: ${{ matrix.set_cargo_home == 'with-v' && '1' || '' }}
run: |
# fetch most recent release name.
BINSTALL_VERSION="$(gh release list --json name --jq '[.[] | select(.name | startswith("v")) | .name] | first')"
if [[ -n $STRIP_V ]]; then BINSTALL_VERSION="${BINSTALL_VERSION#v*}"; fi
echo "Setting BINSTALL_VERSION=$BINSTALL_VERSION"
echo "BINSTALL_VERSION=$BINSTALL_VERSION" >> "$GITHUB_ENV"
- name: Install `cargo-binstall` using scripts
shell: bash
run: ./install-from-binstall-release.sh
Expand Down

0 comments on commit 8111fa2

Please sign in to comment.