Skip to content

Commit 2b0231b

Browse files
committed
fix: generate profiles.json.sha256 in build, simplify sha256 URL for nightly compat
fix #1 - build.sh: generate config/profiles.json.sha256 after merge (committed to repo) - quickstart.sh/ps1: use ${config_url}.sha256 for all config URLs (works for default, custom, nightly) - nightly.yml: commit config/profiles.json + .sha256, remove separate sha256 step - release.yml: include config/profiles.json.sha256 in release assets - release.sh: remove separate sha256 generation, use config/profiles.json.sha256
1 parent a5f2e1a commit 2b0231b

9 files changed

Lines changed: 15 additions & 41 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ jobs:
8282
if: steps.check.outputs.exists == 'false'
8383
run: bash scripts/build.sh
8484

85-
- name: Generate SHA256 checksum
86-
if: steps.check.outputs.exists == 'false'
87-
run: shasum -a 256 config/profiles.json | awk '{print $1}' > dist/profiles.json.sha256
88-
8985
- name: Commit dist
9086
if: steps.check.outputs.exists == 'false'
9187
run: |
9288
VERSION="${{ steps.check.outputs.version }}"
9389
DATE="${{ steps.check.outputs.date_display }}"
9490
git config user.name "github-actions[bot]"
9591
git config user.email "github-actions[bot]@users.noreply.github.com"
96-
git add dist/
92+
git add dist/ config/profiles.json config/profiles.json.sha256
9793
git commit -m "nightly: Nightly @ ${DATE} (v${VERSION})" || echo "No changes to commit"
9894
9995
- name: Tag and push
@@ -132,4 +128,4 @@ jobs:
132128
files: |
133129
dist/quickstart.sh
134130
dist/quickstart.ps1
135-
dist/profiles.json.sha256
131+
config/profiles.json.sha256

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ jobs:
7777
files: |
7878
dist/quickstart.sh
7979
dist/quickstart.ps1
80+
config/profiles.json.sha256

config/profiles.json.sha256

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f11eb0443b3bc103e2a649f14686578e796352bb36817555bb10e0b7d1f79ae7

dist/quickstart.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,7 @@ function Show-Banner {
10271027
# ============================================
10281028
function Test-ConfigChecksum {
10291029
param([string]$Path, [string]$Url)
1030-
if ($Url -eq $DEFAULT_CFG_URL) {
1031-
$sha256Url = "https://github.com/MomoLawson/Quickstart-PC/releases/download/v${VERSION}/profiles.json.sha256"
1032-
} else {
1033-
$sha256Url = "${Url}.sha256"
1034-
}
1030+
$sha256Url = "${Url}.sha256"
10351031
try {
10361032
$expectedHash = (Invoke-WebRequestWithProxy -Uri $sha256Url -TimeoutSec 30 -ErrorAction Stop).Content.Trim()
10371033
$actualHash = (Get-FileHash -Path $Path -Algorithm SHA256).Hash.ToLower()

dist/quickstart.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,13 +1626,7 @@ get_linux_field() {
16261626
verify_config_checksum() {
16271627
local config_file="$1"
16281628
local config_url="$2"
1629-
local sha256_url
1630-
1631-
if [[ "$config_url" == "$DEFAULT_CFG_URL" ]]; then
1632-
sha256_url="https://github.com/MomoLawson/Quickstart-PC/releases/download/v${VERSION}/profiles.json.sha256"
1633-
else
1634-
sha256_url="${config_url}.sha256"
1635-
fi
1629+
local sha256_url="${config_url}.sha256"
16361630

16371631
local expected_hash
16381632
local actual_hash

scripts/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ if [[ -f "$SRC_FILE" ]]; then
7474
echo " Size: $(wc -c < "$DIST_FILE") bytes"
7575
fi
7676

77+
# Generate SHA256 checksum for profiles.json (committed to repo, used by scripts at runtime)
78+
if [[ -f "$CONFIG_DIR/profiles.json" ]]; then
79+
shasum -a 256 "$CONFIG_DIR/profiles.json" | awk '{print $1}' > "$CONFIG_DIR/profiles.json.sha256"
80+
echo "[✓] SHA256: $CONFIG_DIR/profiles.json.sha256"
81+
fi
82+
7783
# Copy language files to dist/lang/
7884
LANG_SRC="$SRC_DIR/lang"
7985
LANG_DIST="$DIST_DIR/lang"

scripts/release.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,13 @@ main() {
127127
notes=$(cat "$PROJECT_DIR/changelog.md")
128128
fi
129129

130-
# Generate SHA256 checksum for profiles.json
131-
echo "[→] Generating SHA256 checksum for profiles.json..."
132-
local profiles_json="$PROJECT_DIR/config/profiles.json"
133-
if [[ -f "$profiles_json" ]]; then
134-
shasum -a 256 "$profiles_json" | awk '{print $1}' > "$PROJECT_DIR/dist/profiles.json.sha256"
135-
echo "[✓] SHA256 checksum generated"
136-
else
137-
echo "[!] profiles.json not found, skipping checksum"
138-
fi
139-
140130
gh release create "v$new_version" \
141131
--title "v$new_version" \
142132
--notes "$notes" \
143133
--prerelease \
144134
"$PROJECT_DIR/dist/quickstart.sh" \
145135
"$PROJECT_DIR/dist/quickstart.ps1" \
146-
"$PROJECT_DIR/dist/profiles.json.sha256"
136+
"$PROJECT_DIR/config/profiles.json.sha256"
147137
echo "[✓] GitHub release created: v$new_version (pre-release)"
148138

149139
# Clear changelog after release

src/quickstart.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,7 @@ function Show-Banner {
10271027
# ============================================
10281028
function Test-ConfigChecksum {
10291029
param([string]$Path, [string]$Url)
1030-
if ($Url -eq $DEFAULT_CFG_URL) {
1031-
$sha256Url = "https://github.com/MomoLawson/Quickstart-PC/releases/download/v${VERSION}/profiles.json.sha256"
1032-
} else {
1033-
$sha256Url = "${Url}.sha256"
1034-
}
1030+
$sha256Url = "${Url}.sha256"
10351031
try {
10361032
$expectedHash = (Invoke-WebRequestWithProxy -Uri $sha256Url -TimeoutSec 30 -ErrorAction Stop).Content.Trim()
10371033
$actualHash = (Get-FileHash -Path $Path -Algorithm SHA256).Hash.ToLower()

src/quickstart.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,13 +1626,7 @@ get_linux_field() {
16261626
verify_config_checksum() {
16271627
local config_file="$1"
16281628
local config_url="$2"
1629-
local sha256_url
1630-
1631-
if [[ "$config_url" == "$DEFAULT_CFG_URL" ]]; then
1632-
sha256_url="https://github.com/MomoLawson/Quickstart-PC/releases/download/v${VERSION}/profiles.json.sha256"
1633-
else
1634-
sha256_url="${config_url}.sha256"
1635-
fi
1629+
local sha256_url="${config_url}.sha256"
16361630

16371631
local expected_hash
16381632
local actual_hash

0 commit comments

Comments
 (0)