|
3 | 3 | # |
4 | 4 | # This source code is licensed under the Apache 2.0 License found in the |
5 | 5 | # LICENSE file in the root directory of this source tree. |
| 6 | +#!/bin/bash |
| 7 | +# Copyright (c) 2024-2025 Six After, Inc. |
| 8 | +# |
| 9 | +# This source code is licensed under the Apache 2.0 License found in the |
| 10 | +# LICENSE file in the root directory of this source tree. |
6 | 11 | set -e |
7 | 12 |
|
8 | 13 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
18 | 23 | mkdir -p tmp |
19 | 24 | rm tmp/*.zip 2>/dev/null || true |
20 | 25 |
|
21 | | -# ------------------------------------------------------------ |
22 | | -# Detect latest release (README method) |
23 | | -# ------------------------------------------------------------ |
24 | 26 | REPO_OWNER="sixafter" |
25 | 27 | REPO_NAME="aes-ctr-drbg" |
26 | 28 | MODULE="github.com/${REPO_OWNER}/${REPO_NAME}" |
27 | 29 |
|
28 | | -TAG=$(curl -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" | jq -r .tag_name) |
29 | | -VERSION=${TAG#v} |
| 30 | +# ------------------------------------------------------------ |
| 31 | +# TAG selection logic: |
| 32 | +# If TAG environment variable is provided, use it. |
| 33 | +# Otherwise default to latest GitHub release (current behavior). |
| 34 | +# ------------------------------------------------------------ |
| 35 | +if [ -n "${TAG:-}" ]; then |
| 36 | + echo "Using provided TAG: ${TAG}" |
| 37 | +else |
| 38 | + echo "No TAG provided, detecting latest GitHub release..." |
| 39 | + TAG=$(curl -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" | jq -r .tag_name) |
| 40 | + if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then |
| 41 | + echo "[ERROR] Could not detect latest release tag from GitHub." >&2 |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +fi |
30 | 45 |
|
31 | | -echo "Latest release: $TAG (version: $VERSION)" |
| 46 | +VERSION=${TAG#v} |
| 47 | +echo "Verifying tag: $TAG (version: $VERSION)" |
| 48 | +echo |
32 | 49 |
|
33 | 50 | # ------------------------------------------------------------ |
34 | 51 | # Portable SHA-256 function (macOS + Linux) |
|
40 | 57 | fi |
41 | 58 |
|
42 | 59 | # ------------------------------------------------------------ |
43 | | -# 1. GitHub Tag ZIP |
| 60 | +# 1. GitHub Tag ZIP (Human-facing) |
44 | 61 | # ------------------------------------------------------------ |
45 | 62 | echo "Downloading GitHub tag archive..." |
46 | 63 | curl -sSfL -o tmp/github.zip \ |
@@ -87,9 +104,20 @@ echo "go mod : $GOMOD_SHA" |
87 | 104 | echo "Proxy : $PROXY_SHA" |
88 | 105 | echo |
89 | 106 |
|
90 | | -if [ "$GITHUB_SHA" != "$GOMOD_SHA" ] || [ "$GITHUB_SHA" != "$PROXY_SHA" ]; then |
91 | | - echo "ERROR: CHECKSUM MISMATCH DETECTED!" |
| 107 | +# The authoritative comparison: direct vs proxy |
| 108 | +if [ "$GOMOD_SHA" != "$PROXY_SHA" ]; then |
| 109 | + echo "[ERROR] Go module ZIP mismatch between direct and proxy!" |
92 | 110 | exit 1 |
93 | 111 | fi |
94 | 112 |
|
| 113 | +echo "✔ Go module ZIP is consistent across direct and proxy." |
| 114 | + |
| 115 | +# GitHub tag ZIP is informational (not authoritative) |
| 116 | +if [ "$GITHUB_SHA" != "$GOMOD_SHA" ]; then |
| 117 | + echo "⚠ WARNING: GitHub's UI ZIP does NOT match the Go module ZIP." |
| 118 | + echo " This is normal: GitHub generates tag archives separately." |
| 119 | +else |
| 120 | + echo "✔ GitHub tag ZIP matches module ZIP (rare but OK)." |
| 121 | +fi |
| 122 | + |
95 | 123 | echo "Go module archive is fully reproducible across GitHub, direct, and proxy." |
0 commit comments