Skip to content

Commit c4060fa

Browse files
committed
refactor: merge version and channel into one common field
Signed-off-by: Jérémy Audiger <jeremy.audiger@icloud.com>
1 parent 5d53771 commit c4060fa

File tree

4 files changed

+34
-40
lines changed

4 files changed

+34
-40
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on:
1717
- ubuntu-22.04
1818
- ubuntu-24.04
19+
- ubuntu-latest
1920
runs-on: ${{ matrix.runs-on }}
2021
steps:
2122
- name: Checkout repository
@@ -40,23 +41,23 @@ jobs:
4041
fail-fast: false
4142
matrix:
4243
include:
43-
- runs-on: ubuntu-latest
44-
channel: stable
45-
- runs-on: ubuntu-latest
46-
channel: nightly
47-
- runs-on: ubuntu-latest-arm
48-
channel: stable
49-
- runs-on: ubuntu-latest-arm
50-
channel: nightly
44+
- runs-on: ubuntu-24.04
45+
version: stable
46+
- runs-on: ubuntu-24.04
47+
version: nightly
48+
- runs-on: ubuntu-24.04-arm
49+
version: stable
50+
- runs-on: ubuntu-24.04-arm
51+
version: nightly
5152
runs-on: ${{ matrix.runs-on }}
52-
continue-on-error: ${{ matrix.runs-on == 'ubuntu-latest-arm' && matrix.channel == 'stable' }} # Brioche stable does not support ARM architecture
53+
continue-on-error: ${{ matrix.runs-on == 'ubuntu-24.04-arm' && matrix.version == 'stable' }} # Brioche stable does not support ARM architecture
5354
steps:
5455
- name: Checkout repository
5556
uses: actions/checkout@v5
5657

5758
- name: Setup Brioche
5859
uses: ./ # Uses an action in the root directory
5960
with:
60-
channel: ${{ matrix.channel }}
61+
version: ${{ matrix.version }}
6162

6263
- *verify-brioche

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Brioche
2424
uses: brioche-dev/setup-brioche@v1
2525
with:
26-
version: "v0.1.5" # Optional, specify a version or use the default (latest)
26+
version: "v0.1.5" # Optional, specify a version or a release channel
2727
install-dir: '/custom/install/path' # Optional, specify a custom installation path
2828

2929
- name: Verify Brioche installation
@@ -32,8 +32,7 @@ jobs:
3232
3333
## Inputs
3434
35-
- `version`: (Optional) The version of Brioche to install. Defaults to `latest`.
36-
- `channel`: (Optional) The channel to install from (stable or nightly).
35+
- `version`: (Optional) The version of Brioche to install. It can be either a specific version (`v0.1.5`) or a release channel (`stable`, `nightly`). Defaults to `stable`.
3736
- `install-dir`: (Optional) The directory where Brioche should be installed. Defaults to `$HOME/.local/bin`.
3837
- `install-apparmor`: (Optional) Enable or disable installation of an AppArmor profile for Brioche. Defaults to `auto`, which will automatically install it if required (e.g. on Ubuntu 24.04).
3938

@@ -66,7 +65,7 @@ jobs:
6665
- name: Setup Brioche
6766
uses: brioche-dev/setup-brioche@v1
6867
# with:
69-
# version: "latest" # Optional
68+
# version: "stable" # Optional
7069
# install-dir: "$HOME/custom/install/path" # Optional
7170
7271
- name: Build package
@@ -85,7 +84,6 @@ This Action uses GitHub's [logging groups](https://docs.github.com/en/actions/us
8584
## Troubleshooting
8685

8786
- Ensure the version specified in the `version` input is valid and available.
88-
- Ensure `version` is not set when `channel=nightly` is specified.
8987
- If Brioche isn't recognized in your shell, make sure the install path is correctly set in your environment.
9088

9189
## License

action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ branding:
66
icon: "box"
77
inputs:
88
version:
9-
description: "Version of Brioche to install"
10-
required: false
11-
default: "latest"
12-
channel:
13-
description: "Channel of Brioche to install"
9+
description: "Version of Brioche to install. It can be either a specific version ('v0.1.5') or a release channel ('stable', 'nightly'). Defaults to 'stable'"
1410
required: false
1511
default: "stable"
1612
install-dir:
@@ -31,5 +27,4 @@ runs:
3127
env:
3228
install_dir: ${{ inputs.install-dir }}
3329
version: ${{ inputs.version }}
34-
channel: ${{ inputs.channel }}
3530
install_apparmor: ${{ inputs.install-apparmor }}

install-brioche.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -euo pipefail
33

44
LATEST_BRIOCHE_VERSION="v0.1.5"
5+
SEMVER_REGEX='^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:\.(?:0|[1-9]\d*))?(?:-(?:(?:[0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?:[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
56

67
# Based on the official install script here:
78
# https://github.com/brioche-dev/brioche.dev/blob/main/public/install.sh
@@ -16,29 +17,25 @@ validate_inputs() {
1617
echo '::error::$HOME must be set'
1718
exit 1
1819
fi
19-
if [ -z "${install_dir:-}" -o -z "${version:-}" -o -z "${channel:-}" -o -z "${install_apparmor:-}" ]; then
20-
echo '::error::$install_dir, $version, $channel, and $install_apparmor must be set'
20+
if [ -z "${install_dir:-}" -o -z "${version:-}" -o -z "${install_apparmor:-}" ]; then
21+
echo '::error::$install_dir, $version, and $install_apparmor must be set'
2122
exit 1
2223
fi
2324

24-
# Validate channel constraints:
25-
# - Only values `stable`, `nightly` are allowed
26-
# - `version` and `channel=nightly` can't be used together, except when 'version=latest'
27-
case "$channel" in
28-
stable)
29-
# Ensure 'latest' is replaced with the actual latest version
30-
if [ "$version" == "latest" ]; then
31-
version=$LATEST_BRIOCHE_VERSION
32-
fi
33-
;;
34-
nightly)
35-
if [ "$version" != "latest" ]; then
36-
echo "::error::version and channel=nightly can't be used together"
25+
# Validate version constraints:
26+
# - Only semver versions are allowed for version
27+
# - Only values `stable`, `nightly` are allowed for release channel
28+
case "$version" in
29+
v*)
30+
if [[ ! $version =~ $SEMVER_REGEX ]]; then
31+
echo "::error::version must be a valid semver"
3732
exit 1
3833
fi
3934
;;
35+
stable|nightly)
36+
;;
4037
*)
41-
echo "::error::channel must be either 'stable' or 'nightly'"
38+
echo "::error::version must be either 'stable', 'nightly' or a semver"
4239
exit 1
4340
;;
4441
esac
@@ -77,10 +74,14 @@ install_brioche() {
7774
# Get the OS and architecture-specific config, such as download URL and AppArmor config
7875
case "$OSTYPE" in
7976
linux*)
80-
case "$(uname -m) $channel" in
81-
"x86_64 stable")
77+
# aarch64 is not currently supported on stable
78+
case "$(uname -m) $version" in
79+
"x86_64 v"*)
8280
brioche_url="https://releases.brioche.dev/$version/x86_64-linux/brioche"
8381
;;
82+
"x86_64 stable")
83+
brioche_url="https://releases.brioche.dev/$LATEST_BRIOCHE_VERSION/x86_64-linux/brioche"
84+
;;
8485
"x86_64 nightly")
8586
brioche_url="https://development-content.brioche.dev/github.com/brioche-dev/brioche/branches/main/x86_64-linux/brioche"
8687
;;
@@ -90,7 +91,6 @@ install_brioche() {
9091
*)
9192
echo "::error::Sorry, Brioche isn't currently supported on your architecture"
9293
echo " Detected architecture: $(uname -m)"
93-
echo " Channel: $channel"
9494
exit 1
9595
;;
9696
esac

0 commit comments

Comments
 (0)