-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (107 loc) · 4.01 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (107 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Release workflow for ModernPath CLI
#
# Triggered when a tag like v0.1.0 is pushed:
# git tag v0.1.0
# git push origin v0.1.0
#
# This workflow:
# 1. Builds binaries for all platforms
# 2. Creates tar.gz archives
# 3. Generates SHA256 checksums
# 4. Creates a GitHub release with all artifacts
# 5. Triggers the homebrew-tap update workflow
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build binaries
run: |
VERSION=${{ steps.version.outputs.VERSION }}
BINARY_NAME="modernpath"
mkdir -p dist
# Build for each platform
platforms=(
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm64"
"windows/amd64"
)
for platform in "${platforms[@]}"; do
IFS='/' read -r os arch <<< "$platform"
binary="${BINARY_NAME}"
if [ "$os" = "windows" ]; then
binary="${BINARY_NAME}.exe"
fi
echo "Building ${os}/${arch}..."
GOOS=$os GOARCH=$arch go build \
-ldflags="-s -w -X github.com/modernpath/cli/cmd.Version=${VERSION}" \
-o "dist/${binary}" .
# Create archive
archive_name="${BINARY_NAME}-${os}-${arch}"
if [ "$os" = "windows" ]; then
(cd dist && zip "${archive_name}.zip" "${binary}")
rm "dist/${binary}"
else
(cd dist && tar -czf "${archive_name}.tar.gz" "${binary}")
rm "dist/${binary}"
fi
done
- name: Generate checksums
id: checksums
run: |
cd dist
# Generate checksums file
sha256sum * > checksums.txt
# Extract individual checksums for homebrew
echo "DARWIN_ARM64=$(sha256sum modernpath-darwin-arm64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "DARWIN_AMD64=$(sha256sum modernpath-darwin-amd64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "LINUX_ARM64=$(sha256sum modernpath-linux-arm64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "LINUX_AMD64=$(sha256sum modernpath-linux-amd64.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "WINDOWS_AMD64=$(sha256sum modernpath-windows-amd64.zip | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-') }}
- name: Update Homebrew Tap
if: ${{ !contains(github.ref, '-') }}
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
gh workflow run update-formula.yml \
-R modernpath/homebrew-tap \
-f version=${{ steps.version.outputs.VERSION }} \
-f darwin_arm64_sha256=${{ steps.checksums.outputs.DARWIN_ARM64 }} \
-f darwin_amd64_sha256=${{ steps.checksums.outputs.DARWIN_AMD64 }} \
-f linux_arm64_sha256=${{ steps.checksums.outputs.LINUX_ARM64 }} \
-f linux_amd64_sha256=${{ steps.checksums.outputs.LINUX_AMD64 }}
- name: Update Scoop bucket
if: ${{ !contains(github.ref, '-') }}
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
continue-on-error: true
run: |
gh workflow run update-formula.yml \
-R ModernPath/scoop-bucket \
-f version=${{ steps.version.outputs.VERSION }} \
-f windows_sha256=${{ steps.checksums.outputs.WINDOWS_AMD64 }} || \
echo "Scoop bucket update skipped (create ModernPath/scoop-bucket repo and re-run)"