diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 36c55d28e..2c6eddc7a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -50,6 +50,7 @@ jobs: run: | use ${{ github.workspace }}/nu/release.nu * version | print + let version = open meta.json | get version echo $env.SIGNING_KEY o> key.gpg # $env | print let arch = match $env.RUNNER_ARCH { @@ -57,7 +58,7 @@ jobs: 'ARM64' => 'arm64', _ => 'amd64' } - fetch release $arch + fetch release $arch $version publish pkg $arch --create-release rm key.gpg @@ -93,10 +94,11 @@ jobs: run: | use ${{ github.workspace }}/nu/release.nu * version | print + let version = open meta.json | get version echo $env.SIGNING_KEY o> key.gpg - fetch release riscv64 + fetch release riscv64 $version publish pkg riscv64 --create-release - fetch release loongarch64 + fetch release loongarch64 $version publish pkg loongarch64 --create-release rm key.gpg diff --git a/Justfile b/Justfile index e6e0eb690..f7eaffb78 100644 --- a/Justfile +++ b/Justfile @@ -35,6 +35,11 @@ _query_plugin := if os_family() == 'windows' { 'nu_plugin_query.exe' } else { 'n default: @just --list --list-prefix "··· " +# Bump Nushell version for supported Linux distributions +bump *OPTIONS: + @overlay use {{ join(NU_DISTRO_PATH, 'nu', 'bump-ver.nu') }}; \ + bump-version {{OPTIONS}} + # Release a new version for Nushell release *OPTIONS: @overlay use {{ join(NU_DISTRO_PATH, 'nu', 'release.nu') }}; \ diff --git a/meta.json b/meta.json index 4236e7eb8..af4545f12 100644 --- a/meta.json +++ b/meta.json @@ -1,7 +1,7 @@ { "name": "nushell", - "version": "0.104.1", - "revision": "0", + "version": "0.105.1", + "revision": 0, "pkgs": { "deb": true, "rpm": true, @@ -13,4 +13,4 @@ "github": "https://github.com/nushell/nushell", "home": "https://www.nushell.sh", "description": "A new type of shell." -} +} \ No newline at end of file diff --git a/nu/bump-ver.nu b/nu/bump-ver.nu new file mode 100644 index 000000000..c344db220 --- /dev/null +++ b/nu/bump-ver.nu @@ -0,0 +1,38 @@ +#!/usr/bin/env nu + +# TODO: +# - [√] Check if the tag of the specified version already exists in local git repository + +export def bump-version [ + version: string, + --revision: int = 0, # Revision number for the version, default is 0 +] { + if not ($version | str replace -ar '^(\d+\.)?(\d+\.)?(\*|\d+)$' '' | is-empty) { + print $'(ansi r)Invalid version number: ($version)(ansi reset)' + exit 7 + } + + if (has-ref $'($version)-($revision)') { + print $'(ansi r)The tag of the specified version already exists: ($version)(ansi reset)' + exit 5 + } + + open meta.json + | update version $version + | update revision $revision + | save -f meta.json + git commit -am $'chore: bump version to ($version) of revision ($revision)' + git tag -am $'chore: bump version to ($version)' $'($version)-($revision)' + git push --follow-tags +} + +# Check if a git repo has the specified ref: could be a branch or tag, etc. +export def has-ref [ + ref: string # The git ref to check +] { + let checkRepo = (do -i { git rev-parse --is-inside-work-tree } | complete) + if not ($checkRepo.stdout =~ 'true') { return false } + # Brackets were required here, or error will occur + let parse = (do -i { git rev-parse --verify -q $ref } | complete) + if ($parse.stdout | is-empty) { false } else { true } +} diff --git a/nu/release.nu b/nu/release.nu index 8d630643c..29f61a12c 100644 --- a/nu/release.nu +++ b/nu/release.nu @@ -24,7 +24,8 @@ const RELEASE_QUERY_URL = 'https://api.github.com/repos/nushell/nushell/releases # Fetch the latest Nushell release package from GitHub export def 'fetch release' [ - arch: string, # The target architecture, e.g. amd64 & arm64 + arch: string, # The target architecture, e.g. amd64 & arm64 + version: string, # The Nushell version to fetch, e.g. 0.105.0 ] { const ARCH_MAP = { amd64: 'x86_64-unknown-linux-musl', @@ -41,7 +42,8 @@ export def 'fetch release' [ ] let assets = http get -H $BASE_HEADER $RELEASE_QUERY_URL | sort-by -r created_at - | select name created_at assets + | select name tag_name created_at assets + | where tag_name =~ $version | get 0 | get assets.browser_download_url let download_url = $assets | where $it =~ ($ARCH_MAP | get $arch) | get 0