Skip to content

Commit ffc258e

Browse files
committed
Add main channel CI builds for installer
1 parent b569cab commit ffc258e

File tree

4 files changed

+158
-15
lines changed

4 files changed

+158
-15
lines changed

.github/workflows/nightly.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: nightly
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
target: x86_64-linux-gnu
19+
os_name: linux
20+
arch: amd64
21+
ext: tar.gz
22+
- os: ubuntu-latest
23+
target: aarch64-linux-gnu
24+
os_name: linux
25+
arch: arm64
26+
ext: tar.gz
27+
- os: macos-13
28+
target: x86_64-macos
29+
os_name: darwin
30+
arch: amd64
31+
ext: tar.gz
32+
- os: macos-14
33+
target: aarch64-macos
34+
os_name: darwin
35+
arch: arm64
36+
ext: tar.gz
37+
- os: windows-latest
38+
target: x86_64-windows
39+
os_name: windows
40+
arch: amd64
41+
ext: zip
42+
43+
runs-on: ${{ matrix.os }}
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: mlugg/setup-zig@v1
48+
with:
49+
version: 0.15.1
50+
51+
- name: Build
52+
shell: bash
53+
run: |
54+
set -euo pipefail
55+
zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }} -Dversion=main-${{ github.sha }}
56+
57+
- name: Package (tar.gz)
58+
if: matrix.ext == 'tar.gz'
59+
shell: bash
60+
run: |
61+
set -euo pipefail
62+
bin="zig-out/bin/nytgames"
63+
chmod +x "${bin}"
64+
pkg="nytgames-cli_main_${{ matrix.os_name }}_${{ matrix.arch }}.tar.gz"
65+
tar -czf "${pkg}" -C "zig-out/bin" "nytgames"
66+
67+
- name: Package (zip)
68+
if: matrix.ext == 'zip'
69+
shell: bash
70+
run: |
71+
set -euo pipefail
72+
bin="zig-out/bin/nytgames.exe"
73+
pkg="nytgames-cli_main_${{ matrix.os_name }}_${{ matrix.arch }}.zip"
74+
7z a "${pkg}" "${bin}"
75+
76+
- name: Upload artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: nightly-${{ matrix.os_name }}-${{ matrix.arch }}
80+
path: |
81+
nytgames-cli_main_${{ matrix.os_name }}_${{ matrix.arch }}.${{ matrix.ext }}
82+
83+
release:
84+
runs-on: ubuntu-latest
85+
needs: build
86+
steps:
87+
- uses: actions/download-artifact@v4
88+
with:
89+
pattern: nightly-*
90+
merge-multiple: true
91+
path: dist
92+
93+
- name: Generate checksums
94+
shell: bash
95+
run: |
96+
set -euo pipefail
97+
cd dist
98+
sha256sum * > checksums.txt
99+
100+
- name: Publish nightly release
101+
uses: ncipollo/release-action@v1
102+
with:
103+
tag: main
104+
name: main
105+
prerelease: true
106+
allowUpdates: true
107+
replacesArtifacts: true
108+
artifacts: |
109+
dist/*

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ curl -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/inst
2626
Options:
2727
- Pin a version:
2828
- `curl -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.sh | NYTGAMES_CLI_VERSION=X.Y.Z bash`
29+
- Install latest main build (CI):
30+
- `curl -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.sh | NYTGAMES_CLI_CHANNEL=main bash`
2931
- Choose install dir: `NYTGAMES_CLI_INSTALL_DIR=~/.local/bin`
3032

3133
### One-line installer (Windows PowerShell)
@@ -41,6 +43,8 @@ Windows builds are currently x64 only.
4143
Options:
4244
- Pin a version:
4345
- `$env:NYTGAMES_CLI_VERSION="X.Y.Z"; curl.exe -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.ps1 | powershell -NoProfile -ExecutionPolicy Bypass -Command -`
46+
- Install latest main build (CI):
47+
- `$env:NYTGAMES_CLI_CHANNEL="main"; curl.exe -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.ps1 | powershell -NoProfile -ExecutionPolicy Bypass -Command -`
4448
- Choose install dir: `$env:NYTGAMES_CLI_INSTALL_DIR="C:\\Users\\You\\bin"`
4549

4650
### Linux packages (optional)

scripts/install.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
param(
22
[string]$Repo = $env:NYTGAMES_CLI_REPO,
3+
[string]$Channel = $env:NYTGAMES_CLI_CHANNEL,
34
[string]$Version = $env:NYTGAMES_CLI_VERSION,
45
[string]$InstallDir = $env:NYTGAMES_CLI_INSTALL_DIR
56
)
@@ -27,7 +28,13 @@ switch ($arch) {
2728
default { throw "unsupported architecture: $arch" }
2829
}
2930

30-
if ([string]::IsNullOrWhiteSpace($Version)) {
31+
if (-not [string]::IsNullOrWhiteSpace($Channel)) {
32+
switch ($Channel) {
33+
"main" { $Version = "main" }
34+
"nightly" { $Version = "main" }
35+
default { throw "unsupported channel: $Channel" }
36+
}
37+
} elseif ([string]::IsNullOrWhiteSpace($Version)) {
3138
$release = Invoke-RestMethod -Headers $headers "https://api.github.com/repos/$Repo/releases/latest"
3239
$tag = $release.tag_name
3340
if (-not $tag) {
@@ -39,7 +46,11 @@ if ([string]::IsNullOrWhiteSpace($Version)) {
3946
}
4047

4148
$asset = "nytgames-cli_${Version}_windows_${arch}.zip"
42-
$baseUrl = "https://github.com/$Repo/releases/download/v$Version"
49+
if ($Version -eq "main") {
50+
$baseUrl = "https://github.com/$Repo/releases/download/main"
51+
} else {
52+
$baseUrl = "https://github.com/$Repo/releases/download/v$Version"
53+
}
4354
$url = "$baseUrl/$asset"
4455
$checksumsUrl = "$baseUrl/checksums.txt"
4556

scripts/install.sh

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33

44
REPO_DEFAULT="ph8n/nytgames-cli"
55
REPO="${NYTGAMES_CLI_REPO:-$REPO_DEFAULT}"
6+
CHANNEL="${NYTGAMES_CLI_CHANNEL:-}"
67
VERSION="${NYTGAMES_CLI_VERSION:-}"
78
INSTALL_DIR="${NYTGAMES_CLI_INSTALL_DIR:-}"
89

@@ -17,6 +18,7 @@ Usage:
1718
1819
Env:
1920
NYTGAMES_CLI_REPO (default: ${REPO_DEFAULT})
21+
NYTGAMES_CLI_CHANNEL (default: latest; set to "main" for CI builds)
2022
NYTGAMES_CLI_VERSION (default: latest)
2123
NYTGAMES_CLI_INSTALL_DIR (default: ~/.local/bin)
2224
EOF
@@ -36,6 +38,10 @@ while [[ $# -gt 0 ]]; do
3638
VERSION="$2"
3739
shift 2
3840
;;
41+
--channel)
42+
CHANNEL="$2"
43+
shift 2
44+
;;
3945
--dir|--install-dir)
4046
INSTALL_DIR="$2"
4147
shift 2
@@ -73,20 +79,33 @@ if [[ -z "$INSTALL_DIR" ]]; then
7379
INSTALL_DIR="${HOME}/.local/bin"
7480
fi
7581

76-
VERSION="${VERSION#v}"
77-
if [[ -z "$VERSION" ]]; then
78-
tag="$(
79-
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
80-
| sed -nE 's/^[[:space:]]*"tag_name":[[:space:]]*"([^"]+)".*$/\1/p' \
81-
| head -n 1
82-
)"
83-
if [[ -z "$tag" ]]; then
84-
echo "failed to resolve latest version from GitHub for ${REPO}" >&2
85-
exit 1
86-
fi
87-
VERSION="${tag#v}"
82+
if [[ -n "$CHANNEL" ]]; then
83+
case "$CHANNEL" in
84+
main|nightly)
85+
tag="main"
86+
VERSION="main"
87+
;;
88+
*)
89+
echo "unsupported channel: ${CHANNEL}" >&2
90+
exit 1
91+
;;
92+
esac
8893
else
89-
tag="v${VERSION}"
94+
VERSION="${VERSION#v}"
95+
if [[ -z "$VERSION" ]]; then
96+
tag="$(
97+
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
98+
| sed -nE 's/^[[:space:]]*"tag_name":[[:space:]]*"([^"]+)".*$/\1/p' \
99+
| head -n 1
100+
)"
101+
if [[ -z "$tag" ]]; then
102+
echo "failed to resolve latest version from GitHub for ${REPO}" >&2
103+
exit 1
104+
fi
105+
VERSION="${tag#v}"
106+
else
107+
tag="v${VERSION}"
108+
fi
90109
fi
91110

92111
asset="nytgames-cli_${VERSION}_${os}_${arch}.tar.gz"

0 commit comments

Comments
 (0)