Skip to content

Commit b9cdddc

Browse files
committed
feat(github): release with goreleaser
Signed-off-by: Fred Myerscough <oniice@gmail.com>
1 parent e2458cf commit b9cdddc

9 files changed

Lines changed: 472 additions & 102 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Go Package Issue
3+
about: Report an issue with the Go package
4+
title: '[GO] '
5+
labels: ['go-package', 'bug']
6+
assignees: ''
7+
8+
---
9+
10+
## Go Package Issue
11+
12+
**Package Version:**
13+
<!-- Which version of the package are you using? -->
14+
```
15+
go list -m github.com/myerscode/aws-meta
16+
```
17+
18+
**Go Version:**
19+
<!-- What version of Go are you using? -->
20+
```
21+
go version
22+
```
23+
24+
**Issue Description:**
25+
<!-- A clear and concise description of what the issue is -->
26+
27+
**Code Example:**
28+
<!-- Please provide a minimal code example that reproduces the issue -->
29+
```go
30+
package main
31+
32+
import (
33+
"fmt"
34+
"github.com/myerscode/aws-meta/pkg/partitions"
35+
"github.com/myerscode/aws-meta/pkg/services"
36+
)
37+
38+
func main() {
39+
// Your code here
40+
}
41+
```
42+
43+
**Expected Behavior:**
44+
<!-- What did you expect to happen? -->
45+
46+
**Actual Behavior:**
47+
<!-- What actually happened? -->
48+
49+
**Error Output:**
50+
<!-- If there's an error, please include the full error message -->
51+
```
52+
```
53+
54+
**Additional Context:**
55+
<!-- Add any other context about the problem here -->
56+
57+
**Environment:**
58+
- OS: <!-- e.g., Ubuntu 20.04, macOS 12.0, Windows 10 -->
59+
- Architecture: <!-- e.g., amd64, arm64 -->
60+
- Go modules enabled: <!-- yes/no -->
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Manual Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
prerelease:
16+
description: 'Create as prerelease'
17+
required: false
18+
default: false
19+
type: boolean
20+
21+
permissions:
22+
contents: write
23+
24+
jobs:
25+
manual-release:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Set up Go
35+
uses: actions/setup-go@v4
36+
with:
37+
go-version: '1.24'
38+
39+
- name: Install GoReleaser
40+
uses: goreleaser/goreleaser-action@v6
41+
with:
42+
install-only: true
43+
44+
- name: Get latest tag and calculate next version
45+
id: get-version
46+
run: |
47+
latest=$(git tag --sort=-version:refname | head -n 1)
48+
if [[ -z "$latest" ]]; then
49+
next="v0.1.0"
50+
else
51+
# Extract version numbers
52+
version=${latest#v}
53+
IFS='.' read -r major minor patch <<< "$version"
54+
55+
case "${{ github.event.inputs.version_type }}" in
56+
"major")
57+
next="v$((major+1)).0.0"
58+
;;
59+
"minor")
60+
next="v$major.$((minor+1)).0"
61+
;;
62+
"patch")
63+
next="v$major.$minor.$((patch+1))"
64+
;;
65+
esac
66+
fi
67+
68+
echo "next_tag=$next" >> $GITHUB_OUTPUT
69+
echo "Previous tag: $latest"
70+
echo "Next tag: $next"
71+
72+
- name: Create and push tag
73+
run: |
74+
git config --local user.email "action@github.com"
75+
git config --local user.name "GitHub Action"
76+
git tag ${{ steps.get-version.outputs.next_tag }}
77+
git push origin ${{ steps.get-version.outputs.next_tag }}
78+
79+
- name: Run GoReleaser
80+
uses: goreleaser/goreleaser-action@v6
81+
with:
82+
distribution: goreleaser
83+
version: '~> v2'
84+
args: release --clean ${{ github.event.inputs.prerelease == 'true' && '--snapshot' || '' }}
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/post-release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Post Release Actions
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
update-documentation:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
ref: main
18+
fetch-depth: 0
19+
20+
- name: Update README with latest version
21+
run: |
22+
# Get the release tag from the event
23+
latest_tag="${{ github.event.release.tag_name }}"
24+
25+
# Update README.md with the latest version in installation instructions
26+
if [ -f README.md ]; then
27+
# Update go get command with latest version
28+
sed -i "s|go get github.com/myerscode/aws-meta@v[0-9]*\.[0-9]*\.[0-9]*|go get github.com/myerscode/aws-meta@$latest_tag|g" README.md
29+
sed -i "s|go get github.com/myerscode/aws-meta$|go get github.com/myerscode/aws-meta@$latest_tag|g" README.md
30+
fi
31+
32+
- name: Update documentation with latest examples
33+
run: |
34+
latest_tag="${{ github.event.release.tag_name }}"
35+
36+
# Update all documentation files with the latest version
37+
find docs/ -name "*.md" -type f -exec sed -i "s|go get github.com/myerscode/aws-meta@v[0-9]*\.[0-9]*\.[0-9]*|go get github.com/myerscode/aws-meta@$latest_tag|g" {} \;
38+
find docs/ -name "*.md" -type f -exec sed -i "s|go get github.com/myerscode/aws-meta$|go get github.com/myerscode/aws-meta@$latest_tag|g" {} \;
39+
40+
- name: Commit documentation updates
41+
run: |
42+
git config --local user.email "action@github.com"
43+
git config --local user.name "GitHub Action"
44+
45+
if git diff --quiet; then
46+
echo "No documentation updates needed"
47+
else
48+
git add README.md docs/
49+
git commit -m "docs: update installation instructions with latest version ${{ github.event.release.tag_name }}"
50+
git push origin main
51+
fi
52+
53+
verify-go-package:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Wait for Go proxy indexing
57+
run: sleep 60 # Wait 1 minute for Go proxy to index
58+
59+
- name: Verify Go package availability
60+
run: |
61+
tag_name="${{ github.event.release.tag_name }}"
62+
module="github.com/myerscode/aws-meta"
63+
64+
echo "🎉 New Go package release: $module@$tag_name"
65+
echo ""
66+
echo "📦 Installation:"
67+
echo "go get $module@$tag_name"
68+
echo ""
69+
echo "🔗 Links:"
70+
echo "- Release: ${{ github.event.release.html_url }}"
71+
echo "- Go Proxy: https://proxy.golang.org/$module/@v/$tag_name.info"
72+
echo "- pkg.go.dev: https://pkg.go.dev/$module@$tag_name"
73+
echo ""
74+
echo "📚 Documentation:"
75+
echo "- API Reference: https://github.com/myerscode/aws-meta/blob/main/docs/methods.md"
76+
echo "- Partitions Package: https://github.com/myerscode/aws-meta/blob/main/docs/partitions.md"
77+
echo "- Services Package: https://github.com/myerscode/aws-meta/blob/main/docs/services.md"
78+
79+
# Try to verify the module is available
80+
max_attempts=3
81+
attempt=1
82+
83+
while [ $attempt -le $max_attempts ]; do
84+
echo "Attempt $attempt/$max_attempts: Checking module availability..."
85+
86+
if go list -m "$module@$tag_name" >/dev/null 2>&1; then
87+
echo "✅ Go module successfully published and available!"
88+
break
89+
else
90+
echo "⏳ Module not yet available, waiting..."
91+
sleep 30
92+
attempt=$((attempt + 1))
93+
fi
94+
done

.github/workflows/release.yml

Lines changed: 27 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ on:
55
- cron: '0 0 * * *'
66
workflow_dispatch:
77

8-
98
permissions:
109
contents: write
11-
packages: write
1210

1311
jobs:
14-
generate:
12+
generate-and-release:
1513
runs-on: ubuntu-latest
16-
outputs:
17-
changes_made: ${{ steps.commit_changes.outputs.changes_made }}
1814

1915
steps:
2016
- name: Checkout
@@ -26,6 +22,11 @@ jobs:
2622
uses: actions/setup-go@v4
2723
with:
2824
go-version: '1.24'
25+
26+
- name: Install GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
install-only: true
2930

3031
- name: Run generate command
3132
run: go run . generate
@@ -40,82 +41,48 @@ jobs:
4041
git add .
4142
if git diff --cached --quiet; then
4243
echo "changed=false" >> $GITHUB_OUTPUT
44+
echo "No changes detected, skipping release"
4345
else
4446
current_date=$(date +'%Y-%m-%d')
45-
git commit -m "Nightly update: $current_date"
47+
git commit -m "nightly: update AWS data $current_date"
4648
echo "changed=true" >> $GITHUB_OUTPUT
49+
echo "Changes detected, proceeding with release"
4750
fi
4851
4952
- name: Push changes if any
5053
if: steps.git-diff.outputs.changed == 'true'
5154
run: git push origin main
5255

53-
- name: Get latest tag
56+
- name: Get latest tag and calculate next version
5457
if: steps.git-diff.outputs.changed == 'true'
5558
id: get-version
5659
run: |
57-
latest=$(git tag --sort=-creatordate | head -n 1)
60+
latest=$(git tag --sort=-version:refname | head -n 1)
5861
if [[ -z "$latest" ]]; then
59-
next="v0.0.0"
62+
next="v0.1.0"
6063
else
61-
IFS='.' read -r major minor patch <<< "${latest#v}"
64+
# Extract version numbers
65+
version=${latest#v}
66+
IFS='.' read -r major minor patch <<< "$version"
67+
# Increment minor version for nightly releases
6268
next="v$major.$((minor+1)).0"
6369
fi
6470
echo "next_tag=$next" >> $GITHUB_OUTPUT
71+
echo "Previous tag: $latest"
72+
echo "Next tag: $next"
6573
66-
- name: Build Go binary
67-
if: steps.git-diff.outputs.changed == 'true'
68-
run: go build -o aws-meta .
69-
70-
- name: Package data manifests
71-
if: steps.git-diff.outputs.changed == 'true'
72-
run: |
73-
mkdir -p release/aws-meta-data
74-
cp -r pkg/data/manifests/* release/aws-meta-data/
75-
cd release
76-
zip -r aws-meta-data.zip aws-meta-data/
77-
78-
- name: Package services
79-
if: steps.git-diff.outputs.changed == 'true'
80-
run: |
81-
mkdir -p release/aws-meta-services
82-
cp pkg/services/list.go release/aws-meta-services/
83-
cd release
84-
zip -r aws-meta-services.zip aws-meta-services/
85-
86-
- name: Get current date
87-
if: steps.git-diff.outputs.changed == 'true'
88-
id: date
89-
run: echo "current=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
90-
91-
- name: Create GitHub release with assets
92-
if: steps.git-diff.outputs.changed == 'true'
93-
uses: softprops/action-gh-release@v2
94-
with:
95-
token: ${{ secrets.GITHUB_TOKEN }}
96-
tag_name: ${{ steps.get-version.outputs.next_tag }}
97-
name: Release ${{ steps.get-version.outputs.next_tag }}
98-
generate_release_notes: true
99-
files: |
100-
./release/aws-meta-data.zip
101-
./release/aws-meta-services.zip
102-
./aws-meta
103-
body: |
104-
Automated nightly release created on ${{ steps.date.outputs.current }}
105-
106-
This release contains all changes since the previous release.
107-
108-
109-
- name: Tag and push new version
74+
- name: Create and push tag
11075
if: steps.git-diff.outputs.changed == 'true'
11176
run: |
11277
git tag ${{ steps.get-version.outputs.next_tag }}
11378
git push origin ${{ steps.get-version.outputs.next_tag }}
11479
115-
- name: Publish Go module (Go proxy)
80+
- name: Run GoReleaser
11681
if: steps.git-diff.outputs.changed == 'true'
117-
run: |
118-
# No special step needed – once the version tag is pushed,
119-
# it is available via the public Go proxy:
120-
# https://proxy.golang.org/<module>@v<version>
121-
echo "Go module published at tag ${{ steps.get-version.outputs.next_tag }}"
82+
uses: goreleaser/goreleaser-action@v6
83+
with:
84+
distribution: goreleaser
85+
version: '~> v2'
86+
args: release --clean
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)