From 992c7da557977fb2e9c8b472f4e84cde9d509cce Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Tue, 23 Jun 2026 18:29:25 +0530 Subject: [PATCH 1/5] Update release and test CI --- .github/scripts/check-go-version-bump.sh | 42 ++++++++++++++++++++++++ .github/scripts/check-version-sync.sh | 25 ++++++++++++++ .github/workflows/release.yaml | 19 +++++++---- .github/workflows/tests.yaml | 9 ++++- aproxy.go | 2 +- snap/snapcraft.yaml | 2 +- 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 .github/scripts/check-go-version-bump.sh create mode 100644 .github/scripts/check-version-sync.sh diff --git a/.github/scripts/check-go-version-bump.sh b/.github/scripts/check-go-version-bump.sh new file mode 100644 index 0000000..87ee638 --- /dev/null +++ b/.github/scripts/check-go-version-bump.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail + +BASE_SHA="${1:-}" +HEAD_SHA="${2:-}" + +if [[ -z "$BASE_SHA" || -z "$HEAD_SHA" ]]; then + echo "Usage: $0 " + exit 1 +fi + +git fetch --no-tags --depth=1 origin "$BASE_SHA" "$HEAD_SHA" + +GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '**/*.go' || true)" +if [[ -z "$GO_CHANGED" ]]; then + echo "No Go files changed; skipping version bump check." + exit 0 +fi + +BASE_VERSION="$(git show "$BASE_SHA:aproxy.go" | sed -n 's/^var version = "\([^"]*\)"$/\1/p' | head -n1)" +CURRENT_VERSION="$(sed -n 's/^var version = "\([^"]*\)"$/\1/p' aproxy.go | head -n1)" + +if [[ -z "$BASE_VERSION" ]]; then + echo "Could not parse base version from aproxy.go at $BASE_SHA" + exit 1 +fi + +if [[ -z "$CURRENT_VERSION" ]]; then + echo "Could not parse current version from aproxy.go" + exit 1 +fi + +LATEST="$(printf '%s\n%s\n' "$BASE_VERSION" "$CURRENT_VERSION" | sort -V | tail -n1)" +if [[ "$CURRENT_VERSION" == "$BASE_VERSION" || "$LATEST" != "$CURRENT_VERSION" ]]; then + echo "Go files changed but version was not bumped." + echo "Base version: $BASE_VERSION" + echo "Current version: $CURRENT_VERSION" + echo "Please bump var version in aproxy.go when modifying Go source files." + exit 1 +fi + +echo "Version bump check passed: $BASE_VERSION -> $CURRENT_VERSION" diff --git a/.github/scripts/check-version-sync.sh b/.github/scripts/check-version-sync.sh new file mode 100644 index 0000000..5b2fd0e --- /dev/null +++ b/.github/scripts/check-version-sync.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +SNAP_VERSION="$(sed -n 's/^version:[[:space:]]*\(.*\)$/\1/p' snap/snapcraft.yaml | head -n1 | tr -d '"' | xargs)" +GO_VERSION="$(sed -n 's/^var version = "\([^"]*\)"$/\1/p' aproxy.go | head -n1)" + +if [[ -z "$SNAP_VERSION" ]]; then + echo "Could not parse version from snap/snapcraft.yaml" + exit 1 +fi + +if [[ -z "$GO_VERSION" ]]; then + echo "Could not parse version from aproxy.go" + exit 1 +fi + +if [[ "$SNAP_VERSION" != "$GO_VERSION" ]]; then + echo "Version mismatch detected" + echo "snap/snapcraft.yaml version: $SNAP_VERSION" + echo "aproxy.go version: $GO_VERSION" + echo "Keep both versions synchronized before merging or releasing." + exit 1 +fi + +echo "Version check passed: $GO_VERSION" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 05cd368..f2bea78 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,12 +1,8 @@ name: Release on: - workflow_dispatch: - inputs: - tag: - description: 'Release tag (e.g., v1.0.0)' - required: true - type: string + push: + branches: [ main ] permissions: contents: write @@ -24,10 +20,19 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + - name: Validate Version Sync + run: | + bash .github/scripts/check-version-sync.sh + - name: Create tag id: tag run: | - TAG="${{ inputs.tag }}" + GO_VERSION="$(sed -n 's/^var version = "\([^"]*\)"$/\1/p' aproxy.go | head -n1)" + if [[ -z "$GO_VERSION" ]]; then + echo "Could not parse version from aproxy.go" + exit 1 + fi + TAG="v${GO_VERSION}" echo "tag=$TAG" >> "$GITHUB_OUTPUT" git tag -a "$TAG" -m "Release $TAG" git push origin "$TAG" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c59b4d7..878b5d9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,7 +2,6 @@ name: Tests on: pull_request: - workflow_call: jobs: test: @@ -22,6 +21,14 @@ jobs: go fmt ./... git diff --exit-code + - name: Check Version Sync + run: | + bash .github/scripts/check-version-sync.sh + + - name: Check Version Bump For Go Changes + run: | + bash .github/scripts/check-go-version-bump.sh "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" + - name: Build and Test run: | go test -race ./... diff --git a/aproxy.go b/aproxy.go index d5392fc..f91b1d4 100644 --- a/aproxy.go +++ b/aproxy.go @@ -24,7 +24,7 @@ import ( "golang.org/x/crypto/cryptobyte" ) -var version = "0.2.4" +var version = "1.0.1" // PrereadConn is a wrapper around net.Conn that supports pre-reading from the underlying connection. // Any Read before the EndPreread can be undone and read again by calling the EndPreread function. diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index dbcc873..500e480 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: aproxy -version: 0.2.5 +version: 1.0.1 summary: Transparent proxy for HTTP and HTTPS/TLS connections. description: | Aproxy is a transparent proxy for HTTP and HTTPS/TLS connections. By From b24368c2779b80fd0dc56b7c274ea036b46a053c Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Tue, 23 Jun 2026 18:44:39 +0530 Subject: [PATCH 2/5] Update script --- .github/scripts/check-go-version-bump.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check-go-version-bump.sh b/.github/scripts/check-go-version-bump.sh index 87ee638..5a98653 100644 --- a/.github/scripts/check-go-version-bump.sh +++ b/.github/scripts/check-go-version-bump.sh @@ -11,9 +11,9 @@ fi git fetch --no-tags --depth=1 origin "$BASE_SHA" "$HEAD_SHA" -GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '**/*.go' || true)" +GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '**/*.go' 'go.mod' 'go.sum' || true)" if [[ -z "$GO_CHANGED" ]]; then - echo "No Go files changed; skipping version bump check." + echo "No Go files or dependencies changed; skipping version bump check." exit 0 fi From 7fc4cd227ac4d95a63ec83a23cc0ec115d6d7ad4 Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Tue, 23 Jun 2026 18:46:17 +0530 Subject: [PATCH 3/5] Update script --- .github/scripts/check-go-version-bump.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check-go-version-bump.sh b/.github/scripts/check-go-version-bump.sh index 5a98653..8bdb45b 100644 --- a/.github/scripts/check-go-version-bump.sh +++ b/.github/scripts/check-go-version-bump.sh @@ -11,7 +11,7 @@ fi git fetch --no-tags --depth=1 origin "$BASE_SHA" "$HEAD_SHA" -GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '**/*.go' 'go.mod' 'go.sum' || true)" +GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '*.go' '**/*.go' 'go.mod' 'go.sum' || true)" if [[ -z "$GO_CHANGED" ]]; then echo "No Go files or dependencies changed; skipping version bump check." exit 0 From ba7b027a4ff3e8ab1a166acbccba343c202c608b Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Wed, 24 Jun 2026 11:47:30 +0530 Subject: [PATCH 4/5] Address review comment --- .github/scripts/check-go-version-bump.sh | 42 ------------------------ .github/workflows/release.yaml | 7 ++-- .github/workflows/tests.yaml | 4 --- aproxy.go | 2 +- snap/snapcraft.yaml | 2 +- 5 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 .github/scripts/check-go-version-bump.sh diff --git a/.github/scripts/check-go-version-bump.sh b/.github/scripts/check-go-version-bump.sh deleted file mode 100644 index 8bdb45b..0000000 --- a/.github/scripts/check-go-version-bump.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -BASE_SHA="${1:-}" -HEAD_SHA="${2:-}" - -if [[ -z "$BASE_SHA" || -z "$HEAD_SHA" ]]; then - echo "Usage: $0 " - exit 1 -fi - -git fetch --no-tags --depth=1 origin "$BASE_SHA" "$HEAD_SHA" - -GO_CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '*.go' '**/*.go' 'go.mod' 'go.sum' || true)" -if [[ -z "$GO_CHANGED" ]]; then - echo "No Go files or dependencies changed; skipping version bump check." - exit 0 -fi - -BASE_VERSION="$(git show "$BASE_SHA:aproxy.go" | sed -n 's/^var version = "\([^"]*\)"$/\1/p' | head -n1)" -CURRENT_VERSION="$(sed -n 's/^var version = "\([^"]*\)"$/\1/p' aproxy.go | head -n1)" - -if [[ -z "$BASE_VERSION" ]]; then - echo "Could not parse base version from aproxy.go at $BASE_SHA" - exit 1 -fi - -if [[ -z "$CURRENT_VERSION" ]]; then - echo "Could not parse current version from aproxy.go" - exit 1 -fi - -LATEST="$(printf '%s\n%s\n' "$BASE_VERSION" "$CURRENT_VERSION" | sort -V | tail -n1)" -if [[ "$CURRENT_VERSION" == "$BASE_VERSION" || "$LATEST" != "$CURRENT_VERSION" ]]; then - echo "Go files changed but version was not bumped." - echo "Base version: $BASE_VERSION" - echo "Current version: $CURRENT_VERSION" - echo "Please bump var version in aproxy.go when modifying Go source files." - exit 1 -fi - -echo "Version bump check passed: $BASE_VERSION -> $CURRENT_VERSION" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f2bea78..0b03f82 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,7 @@ name: Release on: - push: - branches: [ main ] + workflow_dispatch: permissions: contents: write @@ -33,6 +32,10 @@ jobs: exit 1 fi TAG="v${GO_VERSION}" + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists. Please bump the version in aproxy.go and snap/snapcraft.yaml before releasing." + exit 1 + fi echo "tag=$TAG" >> "$GITHUB_OUTPUT" git tag -a "$TAG" -m "Release $TAG" git push origin "$TAG" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 878b5d9..5c8608c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -25,10 +25,6 @@ jobs: run: | bash .github/scripts/check-version-sync.sh - - name: Check Version Bump For Go Changes - run: | - bash .github/scripts/check-go-version-bump.sh "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" - - name: Build and Test run: | go test -race ./... diff --git a/aproxy.go b/aproxy.go index f91b1d4..085a71e 100644 --- a/aproxy.go +++ b/aproxy.go @@ -24,7 +24,7 @@ import ( "golang.org/x/crypto/cryptobyte" ) -var version = "1.0.1" +var version = "0.2.5" // PrereadConn is a wrapper around net.Conn that supports pre-reading from the underlying connection. // Any Read before the EndPreread can be undone and read again by calling the EndPreread function. diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 500e480..dbcc873 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: aproxy -version: 1.0.1 +version: 0.2.5 summary: Transparent proxy for HTTP and HTTPS/TLS connections. description: | Aproxy is a transparent proxy for HTTP and HTTPS/TLS connections. By From ac3f23539624ab683c1469dfd1b6754e8afdba1a Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Wed, 24 Jun 2026 11:49:17 +0530 Subject: [PATCH 5/5] Add workflow call back --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5c8608c..f7d3bd3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,6 +2,7 @@ name: Tests on: pull_request: + workflow_call: jobs: test: