Skip to content

Commit d9dde36

Browse files
authored
Revert the changes (#166)
GitHub release has option set which release is your latest
1 parent 88a8833 commit d9dde36

File tree

4 files changed

+14
-187
lines changed

4 files changed

+14
-187
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,180 +1,41 @@
11
# .github/workflows/release.yml
2-
name: release
2+
name: goreleaser
33

44
on:
55
push:
66
# run only against tags
77
tags:
8-
- "v*"
8+
- "*"
99

1010
permissions:
1111
contents: write
12+
# packages: write
13+
# issues: write
14+
# id-token: write
1215

1316
jobs:
1417
goreleaser:
1518
runs-on: ubuntu-latest
16-
outputs:
17-
tag: ${{ steps.get_tag.outputs.tag }}
1819
steps:
19-
- name: Get tag
20-
id: get_tag
21-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
22-
2320
- name: Checkout
2421
uses: actions/checkout@v4
2522
with:
2623
fetch-depth: 0
27-
2824
- name: Set up Go
2925
uses: actions/setup-go@v5
3026
with:
3127
go-version: stable
32-
28+
# More assembly might be required: Docker logins, GPG, etc.
29+
# It all depends on your needs.
3330
- name: Run GoReleaser
3431
uses: goreleaser/goreleaser-action@v6
3532
with:
33+
# either 'goreleaser' (default) or 'goreleaser-pro'
3634
distribution: goreleaser
35+
# 'latest', 'nightly', or a semver
3736
version: "~> v2"
3837
args: release --clean
3938
env:
4039
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
42-
verify-and-publish:
43-
needs: goreleaser
44-
runs-on: ubuntu-latest
45-
env:
46-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
TAG: ${{ needs.goreleaser.outputs.tag }}
48-
steps:
49-
- name: Get release info
50-
id: release
51-
run: |
52-
echo "Fetching draft release for tag: $TAG"
53-
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases \
54-
--jq ".[] | select(.tag_name == \"$TAG\" and .draft == true) | .id")
55-
56-
if [ -z "$RELEASE_ID" ]; then
57-
echo "ERROR: No draft release found for tag $TAG"
58-
exit 1
59-
fi
60-
61-
echo "Found draft release ID: $RELEASE_ID"
62-
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
63-
64-
- name: Verify asset count
65-
run: |
66-
echo "Verifying assets for release ID: ${{ steps.release.outputs.release_id }}"
67-
68-
ASSETS=$(gh api repos/${{ github.repository }}/releases/${{ steps.release.outputs.release_id }}/assets)
69-
ASSET_COUNT=$(echo "$ASSETS" | jq length)
70-
71-
echo "Found $ASSET_COUNT assets"
72-
echo "$ASSETS" | jq -r '.[].name'
73-
74-
# Expect: hostlink_Linux_x86_64.tar.gz, hostlink_Linux_arm64.tar.gz, checksums.txt
75-
if [ "$ASSET_COUNT" -lt 3 ]; then
76-
echo "ERROR: Expected at least 3 assets, found $ASSET_COUNT"
77-
exit 1
78-
fi
79-
80-
# Verify required assets exist
81-
for asset in "hostlink_Linux_x86_64.tar.gz" "hostlink_Linux_arm64.tar.gz" "checksums.txt"; do
82-
if ! echo "$ASSETS" | jq -e ".[] | select(.name == \"$asset\")" > /dev/null; then
83-
echo "ERROR: Missing required asset: $asset"
84-
exit 1
85-
fi
86-
done
87-
88-
echo "All required assets present"
89-
90-
- name: Download assets
91-
run: |
92-
mkdir -p assets
93-
cd assets
94-
95-
RELEASE_ID="${{ steps.release.outputs.release_id }}"
96-
ASSETS=$(gh api repos/${{ github.repository }}/releases/$RELEASE_ID/assets)
97-
98-
for asset in "hostlink_Linux_x86_64.tar.gz" "hostlink_Linux_arm64.tar.gz" "checksums.txt"; do
99-
echo "Downloading $asset..."
100-
ASSET_ID=$(echo "$ASSETS" | jq -r ".[] | select(.name == \"$asset\") | .id")
101-
gh api repos/${{ github.repository }}/releases/assets/$ASSET_ID \
102-
-H "Accept: application/octet-stream" > "$asset"
103-
echo "Downloaded $asset ($(stat -c%s "$asset") bytes)"
104-
done
105-
106-
- name: Validate gzip files
107-
run: |
108-
cd assets
109-
110-
for tarball in hostlink_Linux_x86_64.tar.gz hostlink_Linux_arm64.tar.gz; do
111-
echo "Validating $tarball..."
112-
113-
# Check gzip magic bytes (1f8b)
114-
MAGIC=$(xxd -p -l 2 "$tarball")
115-
if [ "$MAGIC" != "1f8b" ]; then
116-
echo "ERROR: $tarball is not a valid gzip file (magic: $MAGIC)"
117-
exit 1
118-
fi
119-
120-
# Verify it can be listed
121-
if ! tar -tzf "$tarball" > /dev/null 2>&1; then
122-
echo "ERROR: $tarball cannot be read by tar"
123-
exit 1
124-
fi
125-
126-
echo "$tarball is valid"
127-
done
128-
129-
- name: Verify checksums
130-
run: |
131-
cd assets
132-
echo "Verifying SHA256 checksums..."
133-
134-
# checksums.txt format: <hash> <filename>
135-
sha256sum -c checksums.txt
136-
137-
echo "All checksums verified"
138-
139-
- name: Test binary execution
140-
run: |
141-
cd assets
142-
echo "Testing x86_64 binary..."
143-
144-
mkdir -p test
145-
tar -xzf hostlink_Linux_x86_64.tar.gz -C test
146-
147-
# Run version check
148-
if ! ./test/hostlink --version; then
149-
echo "ERROR: hostlink --version failed"
150-
exit 1
151-
fi
152-
153-
echo "Binary execution test passed"
154-
155-
- name: Publish release
156-
run: |
157-
RELEASE_ID="${{ steps.release.outputs.release_id }}"
158-
159-
# Retry logic with exponential backoff
160-
MAX_RETRIES=3
161-
DELAYS=(5 15 45)
162-
163-
for i in $(seq 0 $((MAX_RETRIES - 1))); do
164-
echo "Attempt $((i + 1)) of $MAX_RETRIES: Publishing release..."
165-
166-
if gh api repos/${{ github.repository }}/releases/$RELEASE_ID \
167-
-X PATCH -f draft=false; then
168-
echo "Release published successfully!"
169-
exit 0
170-
fi
171-
172-
if [ $i -lt $((MAX_RETRIES - 1)) ]; then
173-
DELAY=${DELAYS[$i]}
174-
echo "Publish failed, retrying in ${DELAY}s..."
175-
sleep $DELAY
176-
fi
177-
done
178-
179-
echo "ERROR: Failed to publish release after $MAX_RETRIES attempts"
180-
exit 1
40+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
41+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.goreleaser.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ before:
1414
- go mod tidy
1515
# you may remove this if you don't need go generate
1616
- go generate ./...
17-
# Note: Tests run on PR (test.yml), not during release
17+
# Run tests before building
18+
- make test
19+
- make test-it
1820

1921
builds:
2022
- id: hostlink
@@ -46,10 +48,6 @@ archives:
4648
dst: scripts
4749
strip_parent: true
4850

49-
checksum:
50-
name_template: 'checksums.txt'
51-
algorithm: sha256
52-
5351
changelog:
5452
sort: asc
5553
filters:
@@ -58,8 +56,6 @@ changelog:
5856
- "^test:"
5957

6058
release:
61-
# Create as draft first, verify assets, then publish
62-
draft: true
6359
footer: >-
6460
6561
---

CONTRIBUTING.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,6 @@ go run main.go
128128
go test -tags=smoke ./test/smoke -run TestHlctl
129129
```
130130

131-
## Release Process
132-
133-
Releases are automated via GitHub Actions and triggered by pushing a version tag.
134-
135-
### Creating a Release
136-
137-
1. Ensure all changes are merged to `main`
138-
2. Create and push a version tag:
139-
```bash
140-
git tag v1.2.3
141-
git push origin v1.2.3
142-
```
143-
3. The CI workflow will automatically:
144-
- Build binaries for linux/amd64 and linux/arm64
145-
- Create a **draft** release with all assets
146-
- Verify all assets are valid (checksums, gzip integrity, binary execution)
147-
- Publish the release (make it visible)
148-
149-
4. Monitor the [Actions tab](https://github.com/selfhost-dev/hostlink/actions) for workflow status
150-
151-
### Important Notes
152-
153-
- **Do NOT create releases manually via GitHub UI.** The automated workflow ensures all release assets are verified before becoming visible to users. Manual releases bypass this verification and may cause installation failures.
154-
- Tags must follow semver format: `v1.0.0`, `v1.2.3`, etc.
155-
- If verification fails, the release remains as a draft for debugging. Check the workflow logs and re-trigger if needed.
156-
157131
### Questions or Issues?
158132

159133
Feel free to open an issue on GitHub or reach out to the maintainers.

scripts/linux/install.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,6 @@ fi
262262

263263
HOSTLINK_TAR=hostlink_$VERSION.tar.gz
264264

265-
# Download the release tarball with retry logic.
266-
# Note: Retry logic handles transient network failures. The release process
267-
# ensures assets exist before the version is visible to /releases/latest API,
268-
# so 404 errors during the publish window are not expected.
269265
download_tar() {
270266
local download_url="https://github.com/selfhost-dev/hostlink/releases/download/${VERSION}/hostlink_Linux_${ARCH}.tar.gz"
271267
local tar_file="$TEMP_DIR/$HOSTLINK_TAR"

0 commit comments

Comments
 (0)