Skip to content

Commit 4133a71

Browse files
committed
build: publish apt repo to 0state-packages
1 parent c56110c commit 4133a71

File tree

5 files changed

+128
-66
lines changed

5 files changed

+128
-66
lines changed

.github/workflows/publish-package-managers.yml

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88

99
permissions:
1010
contents: read
11-
pages: write
12-
id-token: write
1311

1412
jobs:
1513
build-manifests:
@@ -56,47 +54,18 @@ jobs:
5654
CXX: g++-13
5755
ICEY_SOURCE_DIR: ${{ github.workspace }}/icey
5856
BUILD_DIR: ${{ github.workspace }}/build-release
59-
APT_BASE_URL: https://nilstate.github.io/icey-cli/apt
57+
APT_BASE_URL: https://nilstate.github.io/0state-packages/icey
6058
run: ./scripts/package-manager-check.sh
6159

62-
- name: Prepare Pages artifact
63-
run: |
64-
rm -rf .stage/pages
65-
mkdir -p .stage/pages/apt
66-
cp -R .stage/apt-repo/. .stage/pages/apt/
67-
cat > .stage/pages/index.html <<'EOF'
68-
<!doctype html>
69-
<html lang="en">
70-
<head>
71-
<meta charset="utf-8">
72-
<title>icey package repositories</title>
73-
</head>
74-
<body>
75-
<p>APT repository: <a href="./apt/">./apt/</a></p>
76-
</body>
77-
</html>
78-
EOF
79-
8060
- uses: actions/upload-artifact@v4
8161
with:
8262
name: package-managers-rendered
8363
path: .stage/package-managers/rendered
8464

85-
- uses: actions/configure-pages@v5
86-
87-
- uses: actions/upload-pages-artifact@v3
65+
- uses: actions/upload-artifact@v4
8866
with:
89-
path: .stage/pages
90-
91-
deploy-apt-pages:
92-
runs-on: ubuntu-24.04
93-
needs: build-manifests
94-
environment:
95-
name: github-pages
96-
url: ${{ steps.deployment.outputs.page_url }}
97-
steps:
98-
- id: deployment
99-
uses: actions/deploy-pages@v4
67+
name: apt-repo
68+
path: .stage/apt-repo
10069

10170
publish-homebrew:
10271
runs-on: ubuntu-24.04
@@ -149,6 +118,59 @@ jobs:
149118
git -C .stage/homebrew-tap commit -m "icey-server ${{ needs.build-manifests.outputs.cli_version }}"
150119
git -C .stage/homebrew-tap push
151120
121+
publish-apt-repo:
122+
runs-on: ubuntu-24.04
123+
needs: build-manifests
124+
steps:
125+
- name: Check package repo credentials
126+
id: gate
127+
env:
128+
PACKAGES_REPO_TOKEN: ${{ secrets.PACKAGES_REPO_TOKEN }}
129+
run: |
130+
if [[ -n "${PACKAGES_REPO_TOKEN:-}" ]]; then
131+
echo "publish=true" >> "$GITHUB_OUTPUT"
132+
else
133+
echo "publish=false" >> "$GITHUB_OUTPUT"
134+
echo "Skipping APT publish: PACKAGES_REPO_TOKEN is not configured."
135+
fi
136+
137+
- uses: actions/checkout@v4
138+
if: steps.gate.outputs.publish == 'true'
139+
140+
- uses: actions/download-artifact@v4
141+
if: steps.gate.outputs.publish == 'true'
142+
with:
143+
name: apt-repo
144+
path: .stage/apt-repo
145+
146+
- name: Checkout package repo
147+
if: steps.gate.outputs.publish == 'true'
148+
uses: actions/checkout@v4
149+
with:
150+
repository: nilstate/0state-packages
151+
token: ${{ secrets.PACKAGES_REPO_TOKEN }}
152+
path: .stage/0state-packages
153+
154+
- name: Publish APT repository
155+
if: steps.gate.outputs.publish == 'true'
156+
env:
157+
PACKAGES_REPO_DIR: ${{ github.workspace }}/.stage/0state-packages
158+
APT_REPO_ROOT: ${{ github.workspace }}/.stage/apt-repo
159+
APT_REPO_PATH: icey
160+
run: ./scripts/publish-apt-repo.sh
161+
162+
- name: Commit package repo update
163+
if: steps.gate.outputs.publish == 'true'
164+
run: |
165+
git -C .stage/0state-packages config user.name "github-actions[bot]"
166+
git -C .stage/0state-packages config user.email "41898282+github-actions[bot]@users.noreply.github.com"
167+
if git -C .stage/0state-packages diff --quiet; then
168+
exit 0
169+
fi
170+
git -C .stage/0state-packages add .nojekyll index.html icey
171+
git -C .stage/0state-packages commit -m "icey-server ${{ needs.build-manifests.outputs.cli_version }}"
172+
git -C .stage/0state-packages push
173+
152174
publish-aur:
153175
runs-on: ubuntu-24.04
154176
needs: build-manifests

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: configure build install package package-deb package-apt package-managers \
2-
publish-homebrew publish-aur publish-apt-site web-install web-build \
2+
publish-homebrew publish-aur publish-apt-repo publish-apt-site web-install web-build \
33
smoke-stream release-check docker-build
44

55
ICEY_SOURCE_DIR ?= ../icey
@@ -34,8 +34,11 @@ publish-homebrew:
3434
publish-aur:
3535
./scripts/publish-aur.sh
3636

37+
publish-apt-repo:
38+
./scripts/publish-apt-repo.sh
39+
3740
publish-apt-site:
38-
./scripts/publish-apt-site.sh
41+
./scripts/publish-apt-repo.sh
3942

4043
web-install:
4144
$(NPM) ci

scripts/publish-apt-repo.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
APT_REPO_ROOT="${APT_REPO_ROOT:-$ROOT_DIR/.stage/apt-repo}"
6+
PACKAGES_REPO_DIR="${PACKAGES_REPO_DIR:?Set PACKAGES_REPO_DIR to the checked out package repository}"
7+
APT_REPO_PATH="${APT_REPO_PATH:-icey}"
8+
DEST_DIR="$PACKAGES_REPO_DIR/$APT_REPO_PATH"
9+
10+
if [[ ! -d "$APT_REPO_ROOT/dists" ]]; then
11+
echo "APT repository root missing or incomplete: $APT_REPO_ROOT" >&2
12+
exit 1
13+
fi
14+
15+
if [[ ! -d "$PACKAGES_REPO_DIR/.git" ]]; then
16+
echo "Package repository root missing or not a git checkout: $PACKAGES_REPO_DIR" >&2
17+
exit 1
18+
fi
19+
20+
mkdir -p "$PACKAGES_REPO_DIR"
21+
touch "$PACKAGES_REPO_DIR/.nojekyll"
22+
23+
rm -rf "$DEST_DIR"
24+
mkdir -p "$DEST_DIR"
25+
cp -R "$APT_REPO_ROOT"/. "$DEST_DIR/"
26+
27+
cat > "$PACKAGES_REPO_DIR/index.html" <<'EOF'
28+
<!doctype html>
29+
<html lang="en">
30+
<head>
31+
<meta charset="utf-8">
32+
<meta name="viewport" content="width=device-width, initial-scale=1">
33+
<title>Icey Packages</title>
34+
</head>
35+
<body>
36+
<main>
37+
<h1>Icey Packages</h1>
38+
<p>Static package repositories for Icey distributions.</p>
39+
<ul>
40+
<li><a href="./icey/">Icey APT repository</a></li>
41+
</ul>
42+
</main>
43+
</body>
44+
</html>
45+
EOF
46+
47+
cat > "$DEST_DIR/index.html" <<'EOF'
48+
<!doctype html>
49+
<html lang="en">
50+
<head>
51+
<meta charset="utf-8">
52+
<meta name="viewport" content="width=device-width, initial-scale=1">
53+
<title>Icey APT Repository</title>
54+
</head>
55+
<body>
56+
<main>
57+
<h1>Icey APT Repository</h1>
58+
<p>This path hosts the static APT repository for <code>icey-server</code>.</p>
59+
</main>
60+
</body>
61+
</html>
62+
EOF
63+
64+
echo "Published APT repository to $DEST_DIR"

scripts/publish-apt-site.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5-
APT_REPO_ROOT="${APT_REPO_ROOT:-$ROOT_DIR/.stage/apt-repo}"
6-
SITE_ROOT="${SITE_ROOT:?Set SITE_ROOT to the document root for the published package site}"
7-
DEST_DIR="$SITE_ROOT/apt"
8-
9-
if [[ ! -d "$APT_REPO_ROOT/dists" ]]; then
10-
echo "APT repository root missing or incomplete: $APT_REPO_ROOT" >&2
11-
exit 1
12-
fi
13-
14-
rm -rf "$DEST_DIR"
15-
mkdir -p "$DEST_DIR"
16-
cp -R "$APT_REPO_ROOT"/. "$DEST_DIR/"
17-
18-
cat > "$SITE_ROOT/index.html" <<'EOF'
19-
<!doctype html>
20-
<html lang="en">
21-
<head>
22-
<meta charset="utf-8">
23-
<title>icey package repositories</title>
24-
</head>
25-
<body>
26-
<p>APT repository: <a href="./apt/">./apt/</a></p>
27-
</body>
28-
</html>
29-
EOF
30-
31-
echo "Published APT site to $SITE_ROOT"
4+
exec "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/publish-apt-repo.sh" "$@"

scripts/render-package-managers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ DEB_URL="${DEB_URL:-https://github.com/nilstate/icey-cli/releases/download/v${CL
101101
DEB_SHA256="${DEB_SHA256:-$(compute_or_placeholder "$DEB_PATH" "REPLACE_WITH_DEB_SHA256")}"
102102
WINDOWS_ZIP_URL="${WINDOWS_ZIP_URL:-https://github.com/nilstate/icey-cli/releases/download/v${CLI_VERSION}/icey-server-${CLI_VERSION}-Windows-x86_64.zip}"
103103
WINDOWS_ZIP_SHA256="${WINDOWS_ZIP_SHA256:-REPLACE_WITH_WINDOWS_ZIP_SHA256}"
104-
APT_BASE_URL="${APT_BASE_URL:-https://nilstate.github.io/icey-cli/apt}"
104+
APT_BASE_URL="${APT_BASE_URL:-https://nilstate.github.io/0state-packages/icey}"
105105
APT_SUITE="${APT_SUITE:-stable}"
106106
APT_COMPONENT="${APT_COMPONENT:-main}"
107107

0 commit comments

Comments
 (0)