Skip to content

Commit 5c73995

Browse files
authored
cleanup(ci): move to using goreleaser (#24)
1 parent 8bde856 commit 5c73995

5 files changed

Lines changed: 87 additions & 368 deletions

File tree

.github/workflows/nightly.yaml

Lines changed: 24 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,35 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
check-and-create-nightly:
14+
check-commits:
1515
runs-on: ubuntu-latest
16-
permissions:
17-
contents: write
1816
outputs:
19-
nightly_version: ${{ env.NIGHTLY_VERSION }}
20-
skip_nightly: ${{ env.SKIP_NIGHTLY }}
21-
changelog_body: ${{ env.CHANGELOG_BODY }}
17+
skip_nightly: ${{ steps.check.outputs.skip_nightly }}
2218
steps:
2319
- name: Checkout code
2420
uses: actions/checkout@v6
2521
with:
2622
fetch-depth: 0
2723

2824
- name: Check for unreleased commits
29-
id: check_commits
25+
id: check
3026
run: |
3127
# Find the latest release tag (any x.y.z release)
3228
LATEST_RELEASE=$(git tag -l 'v*.*.*' --sort=-version:refname | grep -v 'prerelease' | grep -v '^nightly' | head -n1)
3329
3430
if [ -z "$LATEST_RELEASE" ]; then
3531
echo "No existing releases found, creating first nightly"
3632
COMMITS_SINCE_RELEASE=$(git rev-list HEAD --count)
37-
LATEST_RELEASE_COMMIT=""
3833
else
3934
echo "Latest release: $LATEST_RELEASE"
4035
COMMITS_SINCE_RELEASE=$(git rev-list ${LATEST_RELEASE}..HEAD --count)
41-
LATEST_RELEASE_COMMIT="$LATEST_RELEASE"
4236
fi
4337
4438
echo "Commits since latest release: $COMMITS_SINCE_RELEASE"
4539
4640
if [ "$COMMITS_SINCE_RELEASE" -eq "0" ]; then
4741
echo "No new commits since latest release, skipping nightly"
48-
echo "SKIP_NIGHTLY=true" >> "$GITHUB_ENV"
42+
echo "skip_nightly=true" >> "$GITHUB_OUTPUT"
4943
exit 0
5044
fi
5145
@@ -59,31 +53,26 @@ jobs:
5953
6054
if [ "$EXISTING_NIGHTLY_COMMIT" = "$CURRENT_COMMIT" ]; then
6155
echo "Nightly release already exists for current commit"
62-
echo "SKIP_NIGHTLY=true" >> "$GITHUB_ENV"
56+
echo "skip_nightly=true" >> "$GITHUB_OUTPUT"
6357
exit 0
6458
fi
6559
66-
# Use fixed nightly tag name
67-
NIGHTLY_VERSION="nightly"
68-
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> "$GITHUB_ENV"
69-
echo "Creating nightly release: $NIGHTLY_VERSION"
70-
71-
- name: Extract changelog for nightly
72-
id: changelog
73-
if: env.SKIP_NIGHTLY != 'true'
74-
run: |
75-
# Extract the Unreleased section from CHANGELOG.md using make target
76-
CHANGELOG_CONTENT=$(make extract-changelog-unreleased)
60+
echo "skip_nightly=false" >> "$GITHUB_OUTPUT"
7761
78-
# Save to environment variable, handling multiline content
79-
{
80-
echo 'CHANGELOG_BODY<<EOF'
81-
echo "$CHANGELOG_CONTENT"
82-
echo 'EOF'
83-
} >> "$GITHUB_ENV"
62+
nightly-release:
63+
needs: check-commits
64+
if: needs.check-commits.outputs.skip_nightly != 'true'
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
id-token: write # Permission for keyless signing
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v6
72+
with:
73+
fetch-depth: 0
8474

8575
- name: Delete existing nightly release and tag
86-
if: env.SKIP_NIGHTLY != 'true'
8776
run: |
8877
# Delete existing nightly release if it exists
8978
if gh release view nightly >/dev/null 2>&1; then
@@ -95,44 +84,11 @@ jobs:
9584
if git rev-parse --verify nightly >/dev/null 2>&1; then
9685
echo "Deleting existing nightly tag"
9786
git tag -d nightly
98-
if ! git push origin :refs/tags/nightly; then
99-
echo "Warning: Failed to delete remote nightly tag" >&2
100-
exit 1
101-
fi
87+
git push origin :refs/tags/nightly 2>/dev/null || true
10288
fi
10389
env:
10490
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10591

106-
- name: Create nightly release
107-
if: env.SKIP_NIGHTLY != 'true'
108-
run: |
109-
VERSION="${{ env.NIGHTLY_VERSION }}"
110-
CURRENT_DATE=$(date -u +%Y-%m-%d)
111-
SHORT_COMMIT=$(git rev-parse --short HEAD)
112-
113-
echo "Creating nightly release: $VERSION"
114-
gh release create "$VERSION" \
115-
--title "Nightly Release ($CURRENT_DATE - $SHORT_COMMIT)" \
116-
--notes "${{ env.CHANGELOG_BODY }}" \
117-
--prerelease
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120-
121-
build-and-upload:
122-
needs: check-and-create-nightly
123-
if: needs.check-and-create-nightly.outputs.skip_nightly != 'true'
124-
runs-on: ubuntu-latest
125-
permissions:
126-
contents: write
127-
id-token: write # Permission for keyless signing
128-
strategy:
129-
matrix:
130-
goos: [linux, windows, darwin]
131-
goarch: [amd64, arm64]
132-
steps:
133-
- name: Checkout code
134-
uses: actions/checkout@v6
135-
13692
- name: Set up Go
13793
uses: actions/setup-go@v6
13894
with:
@@ -141,19 +97,10 @@ jobs:
14197
- name: Install cosign
14298
uses: sigstore/cosign-installer@v4.0.0
14399

144-
- name: Build release artifacts
145-
env:
146-
GOOS: ${{ matrix.goos }}
147-
GOARCH: ${{ matrix.goarch }}
148-
run: make build-release package-release
149-
150-
- name: Sign release artifacts
151-
env:
152-
GOOS: ${{ matrix.goos }}
153-
GOARCH: ${{ matrix.goarch }}
154-
run: make sign-release
155-
156-
- name: Upload assets to nightly release
157-
run: make upload-release-assets VERSION="${{ needs.check-and-create-nightly.outputs.nightly_version }}"
100+
- name: Run GoReleaser
101+
uses: goreleaser/goreleaser-action@v6
102+
with:
103+
version: '~> v2'
104+
args: release --nightly --clean
158105
env:
159106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/prerelease.yaml

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -12,97 +12,27 @@ on:
1212
type: string
1313

1414
jobs:
15-
determine-version:
15+
prerelease:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
contents: write
19-
outputs:
20-
prerelease_version: ${{ env.PRERELEASE_VERSION }}
21-
changelog_body: ${{ env.CHANGELOG_BODY }}
19+
id-token: write # Permission for keyless signing
2220
steps:
2321
- name: Checkout code
2422
uses: actions/checkout@v6
2523
with:
2624
fetch-depth: 0
25+
ref: ${{ inputs.tag || '' }}
2726

28-
- name: Extract version from tag
29-
id: get_version
27+
- name: Validate prerelease tag
3028
run: |
31-
# Get version from tag (either from push event or manual input)
3229
if [ "${{ github.event_name }}" = "push" ]; then
3330
VERSION="${{ github.ref_name }}"
3431
else
3532
VERSION="${{ inputs.tag }}"
3633
fi
37-
38-
# Validate version format using make target
3934
make validate-prerelease-tag VERSION="$VERSION"
4035
41-
echo "PRERELEASE_VERSION=$VERSION" >> "$GITHUB_ENV"
42-
echo "Pre-release version: $VERSION"
43-
44-
- name: Extract changelog
45-
id: changelog
46-
run: |
47-
VERSION="${{ env.PRERELEASE_VERSION }}"
48-
# Extract the base release version (without -rc.N suffix)
49-
RELEASE_VERSION=$(echo "$VERSION" | sed 's/-rc\.[0-9]*$//')
50-
51-
# Extract changelog using make target (tries version-specific, then unreleased)
52-
CHANGELOG_CONTENT=$(make extract-changelog-version VERSION="$RELEASE_VERSION" 2>/dev/null || echo "Pre-release build for ${RELEASE_VERSION}. See CHANGELOG.md for details.")
53-
54-
# Save to environment variable, handling multiline content
55-
{
56-
echo 'CHANGELOG_BODY<<EOF'
57-
echo "$CHANGELOG_CONTENT"
58-
echo 'EOF'
59-
} >> "$GITHUB_ENV"
60-
61-
- name: Create or update pre-release
62-
run: |
63-
VERSION="${{ env.PRERELEASE_VERSION }}"
64-
65-
# Check if release already exists
66-
if gh release view "$VERSION" >/dev/null 2>&1; then
67-
echo "Pre-release $VERSION already exists, checking if changelog needs to be updated..."
68-
69-
# Get current release notes
70-
CURRENT_NOTES=$(gh release view "$VERSION" --json body -q .body)
71-
72-
# Check if changelog content is already in the notes
73-
if echo "$CURRENT_NOTES" | grep -qF "${{ env.CHANGELOG_BODY }}"; then
74-
echo "Changelog already present in release notes, skipping update..."
75-
else
76-
echo "Appending changelog to existing release notes..."
77-
NEW_NOTES="${CURRENT_NOTES}\n\n---\n\n${{ env.CHANGELOG_BODY }}"
78-
gh release edit "$VERSION" --notes "$NEW_NOTES"
79-
fi
80-
else
81-
echo "Creating pre-release $VERSION..."
82-
gh release create "$VERSION" \
83-
--title "$VERSION" \
84-
--notes "${{ env.CHANGELOG_BODY }}" \
85-
--prerelease
86-
fi
87-
env:
88-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89-
90-
build-and-upload:
91-
needs: determine-version
92-
runs-on: ubuntu-latest
93-
permissions:
94-
contents: write
95-
id-token: write # Permission for keyless signing
96-
strategy:
97-
matrix:
98-
goos: [linux, windows, darwin]
99-
goarch: [amd64, arm64]
100-
steps:
101-
- name: Checkout code
102-
uses: actions/checkout@v6
103-
with:
104-
fetch-depth: 0
105-
10636
- name: Set up Go
10737
uses: actions/setup-go@v6
10838
with:
@@ -111,20 +41,10 @@ jobs:
11141
- name: Install cosign
11242
uses: sigstore/cosign-installer@v4.0.0
11343

114-
- name: Build release artifacts
115-
env:
116-
GOOS: ${{ matrix.goos }}
117-
GOARCH: ${{ matrix.goarch }}
118-
VERSION: ${{ needs.determine-version.outputs.prerelease_version }}
119-
run: make build-release package-release
120-
121-
- name: Sign release artifacts
122-
env:
123-
GOOS: ${{ matrix.goos }}
124-
GOARCH: ${{ matrix.goarch }}
125-
run: make sign-release
126-
127-
- name: Upload assets to release
128-
run: make upload-release-assets VERSION="${{ needs.determine-version.outputs.prerelease_version }}"
44+
- name: Run GoReleaser
45+
uses: goreleaser/goreleaser-action@v6
46+
with:
47+
version: '~> v2'
48+
args: release --clean
12949
env:
13050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)