-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (173 loc) · 6.49 KB
/
release.yml
File metadata and controls
205 lines (173 loc) · 6.49 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Build & Release AWSCLI-Addons
run-name: "Build & Release ${{ inputs.version || github.ref_name }}"
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.2.3)'
required: true
type: string
force:
description: 'Force update existing release'
required: false
type: boolean
default: false
env:
RAW_VERSION: ${{ inputs.version || github.ref_name }}
REPO_URL: "https://github.com/${{ github.repository }}"
permissions:
contents: write
# packages: write
# actions: read
jobs:
check_version:
name: "Check if Release Exists"
runs-on: ubuntu-latest
outputs:
clean_version: ${{ steps.version_logic.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Version & Availability Logic
id: version_logic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Add 'v' only if it's missing
[[ "$RAW_VERSION" == v* ]] && VERSION="$RAW_VERSION" || VERSION="v$RAW_VERSION"
# Validate Format (v1.2.3)
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid format: $VERSION. Use 1.2.3 or v1.2.3"
exit 1
fi
# Check GitHub for existing release
if gh release view "$VERSION" >/dev/null 2>&1 && [ "${{ inputs.force }}" != "true" ]; then
echo "::error::Release $VERSION already exists. Re-run with 'force: true'."
exit 1
fi
# Export for other jobs
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
name: Build (${{ matrix.os }})
needs: [check_version]
env:
VERSION: ${{ needs.check_version.outputs.clean_version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-15-intel, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Detect OS and ARCH
id: info
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
[ "$ARCH" == "x86_64" ] && ARCH="amd64"
[ "$ARCH" == "aarch64" ] && ARCH="arm64"
# Set the output variable
echo "artifact_name=awscli-addons-${OS}-${ARCH}" >> $GITHUB_OUTPUT
- name: Build Binary
run: |
./tools/build.sh quick "${VERSION}"
# Move the binary to the unique name defined above
mv dist/awscli-addons "dist/${{ steps.info.outputs.artifact_name }}"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.info.outputs.artifact_name }}
path: dist/${{ steps.info.outputs.artifact_name }}
publish-docker:
needs: [check_version]
uses: ./.github/workflows/docker.yml
with:
version: ${{ needs.check_version.outputs.clean_version }}
push: false
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
release:
name: Create Release
needs: [check_version, build, publish-docker]
env:
VERSION: ${{ needs.check_version.outputs.clean_version }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
pattern: awscli-addons-*
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum awscli-addons-* > checksums.txt
cat checksums.txt
- name: Create Manual Instructions
id: manual_notes
run: |
# Get previous tag. If none exists, get the first commit
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD | tail -n 1)
cat > manual_notes.md << EOF
# 🚀 Release ${VERSION}
## 📦 Installation
Install the latest binary for your system instantly:
\`\`\`bash
curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/main/tools/installer.sh | bash
\`\`\`
## 🏗️ Available Binaries
| Platform | Architecture | Binary |
|----------|--------------|--------|
| Linux | AMD64 | [awscli-addons-linux-amd64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-linux-amd64) |
| Linux | ARM64 | [awscli-addons-linux-arm64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-linux-arm64) |
| macOS (Intel) | AMD64 | [awscli-addons-darwin-amd64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-darwin-amd64) |
| macOS (Apple Silicon) | ARM64 | [awscli-addons-darwin-arm64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-darwin-arm64) |
Download the appropriate binary for your platform and make it executable:
\`\`\`bash
wget ${REPO_URL}/releases/download/${VERSION}/<Binary>
chmod +x <Binary>
sudo mv <Binary> /usr/local/bin/<Binary>
\`\`\`
## 🛡️ Verification
\`\`\`bash
# Linux
sha256sum -c checksums.txt
# macOS
shasum -a 256 -c checksums.txt
\`\`\`
## 📋 What's Changed
EOF
# Generate changelog between previous tag and current commit
git log ${PREV_TAG}..HEAD --oneline --pretty=format:"* %s (%h)" >> manual_notes.md
- name: Force Update Git Tag
id: update_tag
if: github.event.inputs.force == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f "$VERSION"
git push origin "$VERSION" --force
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
body_path: manual_notes.md
files: ./artifacts/*
append_body: false
generate_release_notes: true
make_latest: ${{ github.event.inputs.force == 'true' && 'legacy' || 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}