-
-
Notifications
You must be signed in to change notification settings - Fork 17
171 lines (143 loc) · 6.35 KB
/
main-deploy.yml
File metadata and controls
171 lines (143 loc) · 6.35 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
name: Main Branch Deployment
on:
# push:
# branches: [ main ]
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(grep 'version = ' library/build.gradle.kts | sed 's/.*version = "\(.*\)".*/\1/')
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Bump version
id: new_version
run: |
CURRENT_VERSION=${{ steps.current_version.outputs.current_version }}
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
PATCH_VERSION=${VERSION_PARTS[2]}
NEW_PATCH=$((PATCH_VERSION + 1))
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEW_PATCH"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
- name: Update version in build.gradle.kts
run: |
sed -i "s/version = \"${{ steps.current_version.outputs.current_version }}\"/version = \"${{ steps.new_version.outputs.new_version }}\"/" library/build.gradle.kts
- name: Setup GPG
run: |
echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" | base64 -d > secring.gpg
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties
echo "signing.secretKeyRingFile=secring.gpg" >> gradle.properties
- name: Setup Maven Central credentials
run: |
echo "mavenCentralUsername=${{ secrets.MAVEN_CENTRAL_USERNAME }}" >> gradle.properties
echo "mavenCentralPassword=${{ secrets.MAVEN_CENTRAL_PASSWORD }}" >> gradle.properties
- name: Build and test
run: ./gradlew build test --no-daemon
- name: Generate coverage report
run: echo "Skipping jacoco — using Kover"
- name: Publish to Maven Central
run: ./gradlew publishToMavenCentral --no-daemon
- name: Create Git tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add library/build.gradle.kts
git commit -m "chore: bump version to ${{ steps.new_version.outputs.new_version }}"
git tag ${{ steps.new_version.outputs.tag }}
git push origin main
git push origin ${{ steps.new_version.outputs.tag }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.new_version.outputs.tag }}
release_name: Release ${{ steps.new_version.outputs.tag }}
body: |
## 🚀 Release ${{ steps.new_version.outputs.tag }}
### What's New
- 🎉 New release of ImagePickerKMP
- 📦 Published to Maven Central
- ✅ All tests passing
- 📊 Code coverage included
### Installation
```kotlin
dependencies {
implementation("io.github.ismoy:imagepickerkmp:${{ steps.new_version.outputs.new_version }}")
}
```
### Documentation
- [Integration Guide](https://github.com/ismoy/ImagePickerKMP/blob/main/INTEGRATION_GUIDE.md)
- [Examples](https://github.com/ismoy/ImagePickerKMP/blob/main/EXAMPLES.md)
- [API Reference](https://github.com/ismoy/ImagePickerKMP/blob/main/API_REFERENCE.md)
### Changes
See [CHANGELOG.md](https://github.com/ismoy/ImagePickerKMP/blob/main/CHANGELOG.md) for detailed changes.
---
*This release was automatically generated by GitHub Actions*
draft: false
prerelease: false
- name: Notify Discord on Deploy Success
if: success()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -s -X POST "$DISCORD_WEBHOOK" \
-H "Content-Type: application/json" \
-d '{"content":""}'
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
with:
args: |
🚀 **Deploy Success** - ImagePickerKMP
**Version:** ${{ steps.new_version.outputs.tag }}
**Repository:** ${{ github.repository }}
**Commit:** ${{ github.sha }}
**Author:** ${{ github.actor }}
📦 **Published to Maven Central**
🏷️ **GitHub Release Created**
🔄 **Version bumped from ${{ steps.current_version.outputs.current_version }} to ${{ steps.new_version.outputs.new_version }}**
🔗 **View Release:** ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.new_version.outputs.tag }}
- name: Notify Discord on Deploy Failure
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -s -X POST "$DISCORD_WEBHOOK" \
-H "Content-Type: application/json" \
-d '{"content":""}'
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
with:
args: |
❌ **Deploy Failed** - ImagePickerKMP
**Version:** ${{ steps.new_version.outputs.tag }}
**Repository:** ${{ github.repository }}
**Commit:** ${{ github.sha }}
**Author:** ${{ github.actor }}
🔗 **View Details:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}