forked from opensearch-project/opensearch-protobufs
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.75 KB
/
Copy pathcleanup-release.yml
File metadata and controls
90 lines (74 loc) · 2.75 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
name: Cleanup release
# Runs after publish-release workflow completes successfully
# Can also be triggered manually for testing
on:
# Triggered when publish-release workflow completes
workflow_run:
workflows: ["Release drafter"]
types:
- completed
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to simulate (e.g., 1.0.0) - used for release notes filename'
required: true
type: string
jobs:
cleanup-release:
name: Cleanup release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: write
pull-requests: write
env:
RELEASE_TAG: ${{ inputs.release_tag || github.event.workflow_run.head_branch }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Increment Version
id: version
uses: nguyenvukhang/semver-increment@v1
with:
increment: minor
version-file: version.properties
version-regex: '^version=(.*)'
- name: Create release notes from current CHANGELOG
run: |
mkdir -p release-notes
RELEASE_NOTES_FILE="release-notes/opensearch-protobufs.release-notes-${{ env.RELEASE_TAG }}.md"
RELEASE_DATE=$(date +%Y-%m-%d)
# Create header with version and date
echo "## Version ${{ env.RELEASE_TAG }} ($RELEASE_DATE) Release Notes" > "$RELEASE_NOTES_FILE"
echo "" >> "$RELEASE_NOTES_FILE"
# Copy changelog content (everything after the [Unreleased] header)
sed -n '/^## \[Unreleased\]/,/^## \[/{ /^## \[Unreleased\]/d; /^## \[/d; p; }' CHANGELOG.md >> "$RELEASE_NOTES_FILE"
echo "Created $RELEASE_NOTES_FILE"
- name: Reset CHANGELOG for next iteration
run: |
cat > CHANGELOG.md << 'EOF'
# CHANGELOG
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
### Added
### Changed
### Removed
### Fixed
### Security
EOF
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Cleanup release ${{ env.RELEASE_TAG }}, prepare ${{ steps.version.outputs.version }}"
signoff: true
branch: cleanup-release/${{ env.RELEASE_TAG }}
base: main
delete-branch: true
title: "Cleanup release ${{ env.RELEASE_TAG }}"
body: |
### Description
Clean up changelog and bump up version.properties after ${{ env.RELEASE_TAG }} release.