Repository navigation
115 lines (100 loc) · 3.67 KB
/
Copy pathrelease.yml
File metadata and controls
115 lines (100 loc) · 3.67 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
name: Release
on:
workflow_run:
workflows: [CI]
branches: [main]
types:
- completed
jobs:
update-version:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.version.outputs.version }}
should_release: ${{ steps.version.outputs.hasNextVersion }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.BOT_PAT }}
- name: Get next version
uses: thenativeweb/get-next-version@main
id: version
with:
prefix: "v"
- name: Update version files and references
if: steps.version.outputs.hasNextVersion == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "📝 Updating to version: $VERSION"
# Update the Version file
echo "$VERSION" > Version
echo "✅ Updated Version file"
# Search for and update version references in other files
echo "🔍 Searching for version patterns to update..."
find . -type f \( -name "main.go" \) \
-exec grep -l "v[0-9]\+\.[0-9]\+\.[0-9]\+" {} \; | \
while read -r file; do
echo " 🔧 Updating $file"
sed -i.bak "s/v[0-9]\+\.[0-9]\+\.[0-9]\+/$VERSION/g" "$file" && rm -f "$file.bak"
done
# Commit all changes together
git config user.name "Enclave Bot"
git config user.email "automation@enclave-runner.de"
git add .
git commit -m "chore: bump version to $VERSION"
git push origin main
echo "✅ Version update complete!"
- name: Tag commit
if: steps.version.outputs.hasNextVersion == 'true'
run: |
git config user.name "Enclave Bot"
git config user.email "automation@enclave-runner.de"
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
release:
runs-on: ubuntu-latest
needs: [update-version]
permissions:
contents: write
actions: read
if: needs.update-version.outputs.should_release == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate release notes
id: release-notes
run: |
CURRENT_TAG="${{ needs.update-version.outputs.tag }}"
# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
# Get commits since last tag
if [ -n "$PREVIOUS_TAG" ]; then
COMMITS=$(git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..$CURRENT_TAG)
CONTRIBUTORS=$(git log --pretty=format:"%an" $PREVIOUS_TAG..$CURRENT_TAG | sort | uniq | sed 's/^/- /')
else
COMMITS=$(git log --pretty=format:"- %s (%h)" $CURRENT_TAG)
CONTRIBUTORS=$(git log --pretty=format:"%an" $CURRENT_TAG | sort | uniq | sed 's/^/- /')
fi
# Create release notes
cat > release_notes.md << EOF
## Changes
$COMMITS
## Contributors
$CONTRIBUTORS
EOF
echo "release_notes_file=release_notes.md" >> $GITHUB_OUTPUT
- name: Release
uses: ncipollo/release-action@v1
with:
name: "Release ${{ needs.update-version.outputs.tag }}"
tag: "${{ needs.update-version.outputs.tag }}"
bodyFile: ${{ steps.release-notes.outputs.release_notes_file }}
token: ${{ secrets.BOT_PAT }}
draft: false
prerelease: false