-
Notifications
You must be signed in to change notification settings - Fork 768
106 lines (95 loc) · 5.21 KB
/
release.yml
File metadata and controls
106 lines (95 loc) · 5.21 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
name: Release
# Controls when the workflow will run
on:
# Triggers on tag pushes that match version pattern
push:
tags:
- 'v*.*.*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version-file: go.mod
- name: "Draft release"
id: "release"
if: github.event_name == 'workflow_dispatch'
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
# Extract version from git tag or use release drafter output
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${{ steps.release.outputs.tag_name }}
fi
COMMIT=${GITHUB_SHA::8}
export VERSION COMMIT
echo "Building with VERSION=$VERSION COMMIT=$COMMIT"
bash build.sh dist
- name: Verify build artifacts
run: |
echo "Checking for build artifacts..."
ls -la ./bin/
# Check if all expected files exist
for file in redis-shake-linux-amd64.tar.gz redis-shake-linux-arm64.tar.gz redis-shake-darwin-amd64.tar.gz redis-shake-darwin-arm64.tar.gz redis-shake-windows-amd64.tar.gz redis-shake-windows-arm64.tar.gz; do
if [ ! -f "./bin/$file" ]; then
echo "Error: $file not found!"
exit 1
else
echo "✓ $file found ($(stat -c%s ./bin/$file) bytes)"
fi
done
- name: Prepare versioned assets
run: |
# Extract version from git tag or use release drafter output
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${{ steps.release.outputs.tag_name }}
fi
echo "Using VERSION=$VERSION"
cd ./bin/
# Create versioned copies of the assets
for file in redis-shake-*.tar.gz; do
if [ -f "$file" ]; then
# Extract OS and ARCH from filename (redis-shake-OS-ARCH.tar.gz)
base_name=$(echo "$file" | sed 's/redis-shake-\(.*\)\.tar\.gz/\1/')
versioned_name="redis-shake-${VERSION}-${base_name}.tar.gz"
cp "$file" "$versioned_name"
echo "Created: $versioned_name"
fi
done
ls -la redis-shake-${VERSION}-*.tar.gz
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
# For tag-triggered builds, these will be auto-detected
# For manual builds, use release drafter outputs
tag_name: ${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}
name: ${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.name }}
body: ${{ github.event_name == 'push' && format('Release {0}', github.ref_name) || steps.release.outputs.body }}
draft: ${{ github.event_name != 'push' }}
prerelease: false
files: |
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-linux-amd64.tar.gz
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-linux-arm64.tar.gz
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-darwin-amd64.tar.gz
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-darwin-arm64.tar.gz
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-windows-amd64.tar.gz
./bin/redis-shake-${{ github.event_name == 'push' && github.ref_name || steps.release.outputs.tag_name }}-windows-arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}