Skip to content

Commit 8bd2c37

Browse files
aacciolyCopilot
andauthored
feat: support for extended/deploy edition (#12)
* ci: downgrade asdf plugin test action to v3 * feat: add extended/deploy edition support * docs: update README to use asdf >= v0.16 commands Refs: https://asdf-vm.com/guide/upgrading-to-v0-16.html#breaking-changes * feat(list-all): add version expansion for extended and extended_withdeploy variants * fix: update version format for extended versions to use hyphen Required for compatibility with mise * fix(list-all): reorder version output so that extended_with_deploy comes first * ci: add test for extended and extended_withdeploy versions * docs: fix list comment to use hyphens Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * docs(readme): add hyphen in with-deploy Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: make major_version and minor_version in lib/utils.bash Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent aec131c commit 8bd2c37

File tree

4 files changed

+90
-21
lines changed

4 files changed

+90
-21
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest]
18+
version: [latest, latest:extended, latest:extended_withdeploy]
1819
runs-on: ${{ matrix.os }}
1920
steps:
2021
- name: asdf_plugin_test
21-
uses: asdf-vm/actions/plugin-test@v4
22+
uses: asdf-vm/actions/plugin-test@v3
2223
with:
2324
command: hugo version
25+
version: ${{ matrix.version }}

README.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
# Contents
1414

15+
- [asdf-hugo ](#asdf-hugo--)
16+
- [Build History](#build-history)
17+
- [Contents](#contents)
1518
- [Dependencies](#dependencies)
1619
- [Install](#install)
17-
- [Why?](#why)
20+
- [Extended builds for Sass/SCSS support and deploy edition](#extended-builds-for-sassscss-support-and-deploy-edition)
1821
- [Contributing](#contributing)
1922
- [License](#license)
2023

@@ -36,13 +39,13 @@ hugo:
3639

3740
```shell
3841
# Show all installable versions
39-
asdf list-all hugo
42+
asdf list all hugo
4043

4144
# Install specific version
4245
asdf install hugo latest
4346

44-
# Set a version globally (on your ~/.tool-versions file)
45-
asdf global hugo latest
47+
# Set a version for your user (writes to your ~/.tool-versions)
48+
asdf set -u hugo latest
4649

4750
# Now hugo commands are available
4851
hugo version
@@ -51,20 +54,36 @@ hugo version
5154
Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to
5255
install & manage versions.
5356

54-
## Extended builds for Sass/SCSS support
57+
## Extended builds for Sass/SCSS support and deploy edition
5558

56-
To install an extended Hugo version with Sass/SCSS support simply prefix the version number in the `asdf install` command with `extended_`.
59+
To install an extended Hugo version with Sass/SCSS support simply prefix the version number in the `asdf install`
60+
command with `extended_`.
5761

5862
```shell
5963
# Install extended hugo version
60-
asdf install hugo extended_0.85.0
64+
asdf install hugo extended_0.154.3
6165

6266
# Now you can manage it like you're used to
63-
asdf global hugo extended_0.85.0
67+
asdf set -u hugo extended_0.154.3
6468
```
6569

66-
**NOTE**: The extended builds for hugo are only available for 64bit Linux, macOS, and Windows.
67-
See the asset list at https://github.com/gohugoio/hugo/releases/latest.
70+
There is also an "extended/deploy" variant which includes the extended build plus additional deployment/cloud
71+
functionality.
72+
73+
```shell
74+
# Install extended/deploy hugo version
75+
asdf install hugo extended_withdeploy-0.154.3
76+
77+
# Manage it the same way
78+
asdf set --home hugo extended_withdeploy-0.154.3
79+
```
80+
81+
See the [Editions section in the Hugo README](https://github.com/gohugoio/hugo/blob/master/README.md#editions) for more
82+
details.
83+
84+
**NOTE**: The extended builds for Hugo (including the with-deploy edition) are only available for 64bit Linux, macOS,
85+
and Windows. See the asset list at https://github.com/gohugoio/hugo/releases/latest.
86+
6887

6988
# Contributing
7089

bin/list-all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ plugin_dir=$(dirname "$(dirname "$current_script_path")")
88
# shellcheck source=lib/utils.bash
99
source "${plugin_dir}/lib/utils.bash"
1010

11-
list_all_versions | sort_versions | xargs echo
11+
list_all_versions | sort_versions | expand_versions | xargs echo

lib/utils.bash

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,57 @@ list_all_versions() {
3737
echo "$tags"
3838
}
3939

40-
# Determine release extension to download for a given version (tar.gz or pkg)
41-
get_release_ext() {
40+
# Expand sorted versions with special variant tags.
41+
# For each version V (one per input line):
42+
# - emit V
43+
# - if V >= 0.43 emit extended-V
44+
# - if V >= 0.137 emit extended_withdeploy-V
45+
expand_versions() {
46+
local regular=()
47+
local extended=()
48+
local extended_withdeploy=()
49+
50+
while IFS= read -r ver; do
51+
[ -z "${ver}" ] && continue
52+
regular+=("$ver")
53+
read -r version_path major_version minor_version <<<"$(parse_version "$ver")"
54+
if [[ "$major_version" =~ ^[0-9]+$ ]] && [[ "$minor_version" =~ ^[0-9]+$ ]]; then
55+
if [ "$major_version" -eq 0 ] && [ "$minor_version" -ge 43 ]; then
56+
extended+=("extended-${ver}")
57+
fi
58+
if [ "$major_version" -eq 0 ] && [ "$minor_version" -ge 137 ]; then
59+
extended_withdeploy+=("extended_withdeploy-${ver}")
60+
fi
61+
fi
62+
done
63+
64+
# Print regular versions first, then extended_withdeploy, then extended
65+
printf '%s\n' "${regular[@]:-}"
66+
printf '%s\n' "${extended_withdeploy[@]:-}"
67+
printf '%s\n' "${extended[@]:-}"
68+
}
69+
70+
# Parse a version string into a plain version path and its major/minor parts.
71+
# Supports prefixes like "extended_", "extended-", "extended_withdeploy_",
72+
# and "extended_withdeploy-".
73+
parse_version() {
4274
local version="$1"
43-
local version_path="${version//extended_/}"
75+
local version_path="${version}"
76+
version_path="${version_path#extended_withdeploy_}"
77+
version_path="${version_path#extended_withdeploy-}"
78+
version_path="${version_path#extended_}"
79+
version_path="${version_path#extended-}"
4480
local major_version
4581
major_version=$(echo "$version_path" | awk -F. '{print $1}')
4682
local minor_version
4783
minor_version=$(echo "$version_path" | awk -F. '{print $2}')
84+
printf '%s %s %s' "$version_path" "$major_version" "$minor_version"
85+
}
86+
87+
# Determine release extension to download for a given version (tar.gz or pkg)
88+
get_release_ext() {
89+
local version="$1"
90+
read -r version_path major_version minor_version <<<"$(parse_version "$version")"
4891
local platform
4992
platform=$(get_platform)
5093

@@ -93,14 +136,13 @@ get_platform() {
93136

94137
download_release() {
95138
local version="$1"
96-
local version_path="${version//extended_/}"
139+
local version_path
97140
local filename="$2"
98-
local platform
99-
platform=$(get_platform)
100141
local major_version
101-
major_version=$(echo "$version_path" | awk -F. '{print $1}')
102142
local minor_version
103-
minor_version=$(echo "$version_path" | awk -F. '{print $2}')
143+
read -r version_path major_version minor_version <<<"$(parse_version "$version")"
144+
local platform
145+
platform=$(get_platform)
104146

105147
# For Mac downloads use universal binaries for releases >= 0.102.0
106148
local arch
@@ -117,7 +159,13 @@ download_release() {
117159

118160
local ext
119161
ext=$(get_release_ext "$version")
120-
local url="${GH_REPO}/releases/download/v${version_path}/hugo_${version}_${platform}-${arch}.${ext}"
162+
# Some expanded variants use '-' between prefix and version (eg
163+
# extended-0.154.3). GitHub release asset names use '_' separators, so
164+
# convert '-' to '_' for the artifact filename while keeping the
165+
# original `version` value used elsewhere.
166+
local version_file
167+
version_file="${version//-/_}"
168+
local url="${GH_REPO}/releases/download/v${version_path}/hugo_${version_file}_${platform}-${arch}.${ext}"
121169

122170
echo "* Downloading $TOOL_NAME release $version..."
123171
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"

0 commit comments

Comments
 (0)