-
Notifications
You must be signed in to change notification settings - Fork 81
234 lines (199 loc) · 8.37 KB
/
push-release.yml
File metadata and controls
234 lines (199 loc) · 8.37 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Push Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version to tag and publish (e.g., 0.40.0)'
required: true
type: string
dry_run:
description: 'Dry run mode (just show what would happen)'
required: true
type: boolean
default: true
permissions:
contents: read
jobs:
push-release:
permissions:
contents: write
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
ref: ${{ github.ref }}
- name: Validate inputs
run: |
# Validate version format
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in format X.Y.Z (e.g., 0.40.0)"
exit 1
fi
- name: Verify release preparation
run: |
# Check if the version is already in CHANGELOG.md
if ! grep -q "## \[${{ inputs.version }}\]" CHANGELOG.md; then
echo "Error: Version ${{ inputs.version }} not found in CHANGELOG.md"
echo "Make sure you have run the 'Prepare Release' workflow and merged the PR first"
exit 1
fi
# Check if repository is clean
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Repository has uncommitted changes"
git status
exit 1
fi
- name: Get last released version
id: last_version
run: |
# Get the latest tag
LAST_TAG=$(git tag --list 'v*' --sort=-version:refname | head -n1)
if [ -z "$LAST_TAG" ]; then
echo "No previous tags found"
LAST_VERSION="0.0.0"
else
LAST_VERSION=${LAST_TAG#v}
fi
echo "last_version=$LAST_VERSION" >> $GITHUB_OUTPUT
echo "Last released version: $LAST_VERSION"
echo "New version: ${{ inputs.version }}"
- name: Validate version increment
run: |
LAST_VERSION="${{ steps.last_version.outputs.last_version }}"
NEW_VERSION="${{ inputs.version }}"
# Simple version comparison (assumes semantic versioning)
if [ "$LAST_VERSION" != "0.0.0" ]; then
if ! printf '%s\n%s\n' "$LAST_VERSION" "$NEW_VERSION" | sort -V -C; then
echo "Error: New version $NEW_VERSION is not greater than last version $LAST_VERSION"
exit 1
fi
fi
- name: Check if tag already exists
run: |
if git tag --list | grep -q "^v${{ inputs.version }}$"; then
echo "Error: Tag v${{ inputs.version }} already exists"
exit 1
fi
- name: Extract changelog content for this release
id: changelog
run: |
.github/workflows/scripts/extract-changelog.sh "${{ inputs.version }}" /tmp/release_content.txt --normalize
- name: Dry run - Show planned changes
if: inputs.dry_run
run: |
# Write to GitHub Step Summary
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
# :rocket: Release Push Dry Run
## Summary
**DRY RUN MODE** - No changes will be made to the repository
## Planned Operations
- **Version to tag**: `v${{ inputs.version }}`
- **Last version**: `v${{ steps.last_version.outputs.last_version }}`
## Git Tags to Create
- `v${{ inputs.version }}` - Main release tag
- `go/v${{ inputs.version }}` - Go module tag
- `collector/cmd/otelarrowcol/v${{ inputs.version }}` - Collector module tag
## GitHub Release
- **Title**: Release v${{ inputs.version }}
- **Tag**: v${{ inputs.version }}
- **Type**: Draft release (latest)
- **Release notes**: Extracted from CHANGELOG.md
## Go Modules
After release, the following modules will be available:
```bash
go get github.com/open-telemetry/otel-arrow/go@v${{ inputs.version }}
go get github.com/open-telemetry/otel-arrow/collector/cmd/otelarrowcol@v${{ inputs.version }}
```
## Release Notes Preview
```
EOF
cat /tmp/release_content.txt >> $GITHUB_STEP_SUMMARY
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
```
## Next Steps
1. Review the planned operations above
2. Run again without dry-run when ready to publish
3. The GitHub release will be created as a draft for final review
---
**Note**: This is a dry run. To execute the actual release push, set `dry_run` to `false`.
EOF
- name: Create GitHub App token
if: '!inputs.dry_run'
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
id: app-token
with:
app-id: ${{ vars.OTELBOT_APP_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
- name: Create git tags
if: '!inputs.dry_run'
run: |
# Configure git
git config user.name otelbot
git config user.email 197425009+otelbot@users.noreply.github.com
# Create main release tag
git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}"
# Create Go module tags
git tag -a "go/v${{ inputs.version }}" -m "Release go/v${{ inputs.version }}"
git tag -a "collector/cmd/otelarrowcol/v${{ inputs.version }}" -m "Release collector/cmd/otelarrowcol/v${{ inputs.version }}"
echo "Created tags:"
git tag --list "v${{ inputs.version }}"
git tag --list "*v${{ inputs.version }}"
- name: Push git tags
if: '!inputs.dry_run'
run: |
# Push all tags for this version
git push origin "v${{ inputs.version }}"
git push origin "go/v${{ inputs.version }}"
git push origin "collector/cmd/otelarrowcol/v${{ inputs.version }}"
echo "Pushed tags:"
echo "- v${{ inputs.version }}"
echo "- go/v${{ inputs.version }}"
echo "- collector/cmd/otelarrowcol/v${{ inputs.version }}"
- name: Create GitHub release
if: '!inputs.dry_run'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Read changelog content into a variable
RELEASE_CONTENT=$(cat /tmp/release_content.txt)
# Create release body content
cat > /tmp/release_body.md << EOF
## What's Changed
${RELEASE_CONTENT}
**Full Changelog**: https://github.com/open-telemetry/otel-arrow/compare/v${{ steps.last_version.outputs.last_version }}...v${{ inputs.version }}
## Go Modules
This release includes the following Go modules:
- github.com/open-telemetry/otel-arrow/go@v${{ inputs.version }}
- github.com/open-telemetry/otel-arrow/collector/cmd/otelarrowcol@v${{ inputs.version }}
EOF
# Create the GitHub release using GitHub CLI
gh release create "v${{ inputs.version }}" \
--title "Release v${{ inputs.version }}" \
--notes-file /tmp/release_body.md \
--draft \
--latest
- name: Summary
run: |
if [ "${{ inputs.dry_run }}" = "true" ]; then
echo ":heavy_check_mark: Dry run completed successfully"
echo "No changes were made to the repository"
echo "Review the planned changes above and run again without dry-run when ready"
else
echo ":heavy_check_mark: Release published successfully"
echo ""
echo "Release details:"
echo "- Version: v${{ inputs.version }}"
echo "- GitHub release: https://github.com/open-telemetry/otel-arrow/releases/tag/v${{ inputs.version }}"
echo ""
echo "Git tags created:"
echo "- v${{ inputs.version }}"
echo "- go/v${{ inputs.version }}"
echo "- collector/cmd/otelarrowcol/v${{ inputs.version }}"
echo ""
echo "Go modules are now available:"
echo "- go get github.com/open-telemetry/otel-arrow/go@v${{ inputs.version }}"
echo "- go get github.com/open-telemetry/otel-arrow/collector/cmd/otelarrowcol@v${{ inputs.version }}"
fi