Skip to content

Commit c8edf3a

Browse files
committed
release - #3
1 parent 4c629bb commit c8edf3a

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

.github/workflows/ready.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ jobs:
3333
# Add all additional jobs you want to run on the ready branch before the merge-to-trunk job
3434
# and make merge-to-trunk depend on them (like it depends on trunk-worthy) to ensure they run before the merge.
3535

36+
mark-trunk-worthy:
37+
name: Trunk-worthy
38+
runs-on: ubuntu-latest
39+
permissions:
40+
statuses: write
41+
contents: read
42+
needs:
43+
- trunk-worthy
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.READY_PUSHER }}
46+
steps:
47+
- name: Mark trunk-worthy
48+
run: |
49+
set -e
50+
gh ext install lakruzz/gh-set-status
51+
gh set-status success "Is trunk-worthy" trunk-worthy
3652
3753
merge-to-trunk:
3854
name: Merge to trunk

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,47 @@ on:
1616
type: string
1717

1818
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
include:
24+
- os: linux
25+
arch: amd64
26+
- os: linux
27+
arch: arm64
28+
- os: darwin
29+
arch: amd64
30+
- os: darwin
31+
arch: arm64
32+
- os: windows
33+
arch: amd64
34+
ext: .exe
35+
- os: windows
36+
arch: arm64
37+
ext: .exe
38+
39+
40+
steps:
41+
- uses: actions/checkout@v6
42+
with:
43+
ref: ${{ github.event.inputs.tag || github.ref }}
44+
fetch-depth: 0 # Fetch full history (needed for release notes generation)
45+
fetch-tags: true # Ensure tags are fetched (needed for release notes generation)
46+
47+
- name: Set up runner environment
48+
uses: ./.github/actions/prep-runner
49+
50+
- name: Build Go binary for ${{ matrix.os }}-${{ matrix.arch }}
51+
uses: ./.github/actions/build-go-binaries
52+
with:
53+
binary-name: utils
54+
os: ${{ matrix.os }}
55+
arch: ${{ matrix.arch }}
56+
ext: ${{ matrix.ext || '' }}
57+
1958
release:
59+
needs: build
2060
runs-on: ubuntu-latest
2161
permissions:
2262
contents: write
@@ -28,6 +68,76 @@ jobs:
2868
fetch-depth: 0 # Fetch full history (needed for release notes generation)
2969
fetch-tags: true # Ensure tags are fetched (needed for release notes generation)
3070

71+
- name: Download all artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
path: artifacts
75+
merge-multiple: true
76+
77+
- name: Prepare release artifacts
78+
run: |
79+
mkdir -p release
80+
find artifacts -type f -exec mv {} release/ \;
81+
ls -la release/
82+
83+
- name: Create release notes
84+
id: release_notes
85+
env:
86+
GITHUB_TOKEN: ${{ github.token }}
87+
run: |
88+
gh ext install devx-cafe/gh-tt
89+
mkdir -p .tmp
90+
gh tt semver note --filename .tmp/RELEASENOTES.md
91+
echo "Generating release notes..."
92+
cat .tmp/RELEASENOTES.md >> $GITHUB_STEP_SUMMARY
93+
94+
# Nice to have a version.txt in the release assets, so we know what commit and tag the release was built from
95+
- name: version.txt
96+
run: |
97+
mkdir -p release
98+
echo "Build from ${{ github.repository }}" > release/version.txt
99+
echo "Tag: ${{ github.ref_name }}" >> release/version.txt
100+
echo "Commit: ${{ github.sha }}" >> release/version.txt
101+
102+
- name: Determine release type
103+
id: release_type
104+
run: |
105+
TAG="${{ github.event.inputs.tag || github.ref_name }}"
106+
# Check if tag contains prerelease markers (- or +) after SemVer core
107+
# Lines 5-6 in trigger: [0-9]+.[0-9]+.[0-9]+* and [a-zA-Z]+[0-9]+.[0-9]+.[0-9]+*
108+
if [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([-]) ]]; then
109+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
110+
echo "is_draft=false" >> $GITHUB_OUTPUT
111+
echo "Release type: PRERELEASE"
112+
elif [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([+]) ]]; then
113+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
114+
echo "is_draft=true" >> $GITHUB_OUTPUT
115+
echo "Release type: DRAFT"
116+
else
117+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
118+
echo "is_draft=false" >> $GITHUB_OUTPUT
119+
echo "Release type: STABLE"
120+
fi
121+
122+
- name: Create Release
123+
uses: softprops/action-gh-release@v1
124+
with:
125+
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
126+
files: release/*
127+
body_path: .tmp/RELEASENOTES.md
128+
draft: ${{ steps.release_type.outputs.is_draft }}
129+
prerelease: ${{ steps.release_type.outputs.is_prerelease }}
130+
token: ${{ secrets.GITHUB_TOKEN }}
131+
132+
133+
134+
---
135+
release:
136+
runs-on: ubuntu-latest
137+
needs: build
138+
139+
steps:
140+
31141
- name: Determine release type
32142
id: release_type
33143
run: |

0 commit comments

Comments
 (0)