Skip to content

Commit 1c7ce20

Browse files
committed
Add GitHub Actions CI/CD workflows and remove legacy CI configs
- Add comprehensive CI workflow with matrix testing (Java 17/21, Gradle 8.5/9.2) - Add automated release workflow that publishes to Maven Central and Gradle Plugin Portal - Add RELEASE.md documentation for release process - Remove obsolete .travis.yml and appveyor.yml configurations - CI runs on every push and PR to master/main - Release workflow triggers on version tags (v* or numeric)
1 parent 00f4f19 commit 1c7ce20

File tree

5 files changed

+323
-7
lines changed

5 files changed

+323
-7
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
java-version: ['17', '21']
17+
gradle-version: ['8.5', '9.2']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up JDK ${{ matrix.java-version }}
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: ${{ matrix.java-version }}
27+
distribution: 'temurin'
28+
29+
- name: Setup Gradle ${{ matrix.gradle-version }}
30+
uses: gradle/gradle-build-action@v2
31+
with:
32+
gradle-version: ${{ matrix.gradle-version }}
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Cache Gradle dependencies
38+
uses: actions/cache@v3
39+
with:
40+
path: |
41+
~/.gradle/caches
42+
~/.gradle/wrapper
43+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
44+
restore-keys: |
45+
${{ runner.os }}-gradle-
46+
47+
- name: Run tests with Gradle ${{ matrix.gradle-version }}
48+
run: ./gradlew clean test --no-daemon
49+
50+
- name: Build plugin with Gradle ${{ matrix.gradle-version }}
51+
run: ./gradlew clean build -x test --no-daemon
52+
53+
- name: Validate plugin
54+
run: ./gradlew validatePlugins --no-daemon
55+
56+
- name: Upload test results
57+
if: always()
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: test-results-java${{ matrix.java-version }}-gradle${{ matrix.gradle-version }}
61+
path: build/test-results/
62+
retention-days: 7
63+
64+
- name: Upload build artifacts
65+
if: matrix.java-version == '17' && matrix.gradle-version == '9.2'
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: build-artifacts
69+
path: build/libs/*.jar
70+
retention-days: 1
71+

.github/workflows/release.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on tags like v2.24, v2.25, etc.
7+
- '[0-9]+.[0-9]+*' # Also supports tags like 2.24, 2.25, etc.
8+
9+
jobs:
10+
release:
11+
name: Build and Release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Need full history for changelog extraction
19+
20+
- name: Set up JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
26+
- name: Extract version from tag
27+
id: version
28+
run: |
29+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
30+
# Tag format: v2.24 -> 2.24
31+
VERSION=${GITHUB_REF#refs/tags/v}
32+
else
33+
# Tag format: 2.24 -> 2.24
34+
VERSION=${GITHUB_REF#refs/tags/}
35+
fi
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "Extracted version: $VERSION"
38+
39+
- name: Update version in gradle.properties
40+
run: |
41+
sed -i "s/^version = .*/version = ${{ steps.version.outputs.version }}/" gradle.properties
42+
cat gradle.properties
43+
44+
- name: Extract changelog for version
45+
id: changelog
46+
run: |
47+
VERSION="${{ steps.version.outputs.version }}"
48+
echo "Extracting changelog for version: $VERSION"
49+
50+
# Extract changelog section for this version using awk
51+
# Pattern: from "## VERSION" to next "## " or end of file
52+
CHANGELOG=$(awk -v version="$VERSION" '
53+
BEGIN { found=0; in_section=0 }
54+
/^## / {
55+
if (in_section) exit # Stop at next version section
56+
if ($0 ~ "^## " version "$" || $0 ~ "^## " version " ") {
57+
found=1
58+
in_section=1
59+
next
60+
}
61+
}
62+
in_section { print }
63+
' CHANGELOG.md)
64+
65+
# If empty, try without the "## " prefix
66+
if [ -z "$CHANGELOG" ]; then
67+
CHANGELOG=$(awk -v version="$VERSION" '
68+
BEGIN { found=0; in_section=0 }
69+
/^## / {
70+
if (in_section) exit
71+
if ($0 ~ "^## " version "$" || $0 ~ "^## " version " ") {
72+
found=1
73+
in_section=1
74+
next
75+
}
76+
}
77+
in_section { print }
78+
' CHANGELOG.md)
79+
fi
80+
81+
# If still empty, use a default message
82+
if [ -z "$CHANGELOG" ]; then
83+
CHANGELOG="See CHANGELOG.md for details."
84+
fi
85+
86+
# Escape for GitHub output (multiline)
87+
{
88+
echo "changelog<<EOF"
89+
echo "$CHANGELOG"
90+
echo "EOF"
91+
} >> $GITHUB_OUTPUT
92+
93+
echo "Changelog extracted (first 200 chars):"
94+
echo "$CHANGELOG" | head -c 200
95+
echo ""
96+
97+
- name: Grant execute permission for gradlew
98+
run: chmod +x gradlew
99+
100+
- name: Build plugin
101+
run: ./gradlew clean build -x test
102+
103+
- name: Publish to Maven Central (Sonatype)
104+
env:
105+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
106+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
107+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
108+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
109+
run: |
110+
./gradlew publishToSonatype closeStagingRepositories
111+
112+
- name: Publish to Gradle Plugin Portal
113+
env:
114+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
115+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
116+
run: |
117+
./gradlew publishPlugins
118+
119+
- name: Create GitHub Release
120+
uses: actions/create-release@v1
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
with:
124+
tag_name: ${{ github.ref }}
125+
release_name: Release ${{ steps.version.outputs.version }}
126+
body: |
127+
## Version ${{ steps.version.outputs.version }}
128+
129+
${{ steps.changelog.outputs.changelog }}
130+
131+
---
132+
133+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.ref }}
134+
draft: false
135+
prerelease: false
136+
continue-on-error: true # Continue even if release creation fails (might already exist)
137+
138+
- name: Create GitHub Release (alternative method)
139+
if: failure() # Only if previous step failed
140+
uses: softprops/action-gh-release@v1
141+
with:
142+
tag_name: ${{ github.ref }}
143+
name: Release ${{ steps.version.outputs.version }}
144+
body: |
145+
## Version ${{ steps.version.outputs.version }}
146+
147+
${{ steps.changelog.outputs.changelog }}
148+
149+
---
150+
151+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.ref }}
152+
draft: false
153+
prerelease: false
154+
env:
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

RELEASE.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Release Process
2+
3+
This document describes how to create a new release of the gradle-nuget-plugin.
4+
5+
## Prerequisites
6+
7+
1. Ensure all changes are committed and pushed to the repository
8+
2. Update `CHANGELOG.md` with the new version and changes
9+
3. Update `gradle.properties` with the new version (remove `-SNAPSHOT` if present)
10+
11+
## Creating a Release
12+
13+
### Option 1: Using Git Tags (Recommended)
14+
15+
1. **Update version in `gradle.properties`**:
16+
```properties
17+
version = 2.24
18+
```
19+
20+
2. **Commit the version change**:
21+
```bash
22+
git add gradle.properties CHANGELOG.md
23+
git commit -m "Release version 2.24"
24+
git push
25+
```
26+
27+
3. **Create and push a tag**:
28+
```bash
29+
# Tag format: v2.24 (recommended) or 2.24
30+
git tag -a v2.24 -m "Release version 2.24"
31+
git push origin v2.24
32+
```
33+
34+
4. **GitHub Actions will automatically**:
35+
- Extract the version from the tag
36+
- Build the plugin
37+
- Publish to Maven Central (Sonatype)
38+
- Publish to Gradle Plugin Portal
39+
- Create a GitHub Release with changelog
40+
41+
### Option 2: Manual Release
42+
43+
If you prefer to create the release manually:
44+
45+
1. **Update version and commit** (same as Option 1, steps 1-2)
46+
47+
2. **Build and publish locally**:
48+
```bash
49+
./gradlew clean build publishToSonatype closeStagingRepositories publishPlugins
50+
```
51+
52+
3. **Create GitHub Release manually**:
53+
- Go to https://github.com/i-net-software/gradle-nuget-plugin/releases/new
54+
- Create a new tag (e.g., `v2.24`)
55+
- Copy the relevant section from `CHANGELOG.md` as the release notes
56+
- Publish the release
57+
58+
## Required GitHub Secrets
59+
60+
The release workflow requires the following secrets to be configured in GitHub:
61+
62+
- `SONATYPE_USERNAME` - Your Sonatype username
63+
- `SONATYPE_PASSWORD` - Your Sonatype password
64+
- `SIGNING_KEY` - Your PGP private key (for signing artifacts)
65+
- `SIGNING_PASSWORD` - Your PGP key passphrase
66+
- `GRADLE_PUBLISH_KEY` - Gradle Plugin Portal API key
67+
- `GRADLE_PUBLISH_SECRET` - Gradle Plugin Portal API secret
68+
69+
To configure secrets:
70+
1. Go to your repository on GitHub
71+
2. Settings → Secrets and variables → Actions
72+
3. Add each secret
73+
74+
## Version Numbering
75+
76+
- Use semantic versioning: `MAJOR.MINOR.PATCH`
77+
- Examples: `2.24`, `2.24.1`, `3.0.0`
78+
- Tag format: `v2.24` (with `v` prefix) or `2.24` (without prefix) - both are supported
79+
80+
## After Release
81+
82+
1. **Update version to next SNAPSHOT** (if continuing development):
83+
```properties
84+
version = 2.25-SNAPSHOT
85+
```
86+
```bash
87+
git add gradle.properties
88+
git commit -m "Bump version to 2.25-SNAPSHOT"
89+
git push
90+
```
91+
92+
2. **Verify the release**:
93+
- Check Maven Central: https://central.sonatype.com/artifact/de.inetsoftware.gradle/gradle-nuget-plugin
94+
- Check Gradle Plugin Portal: https://plugins.gradle.org/plugin/de.inetsoftware.nuget
95+
- Check GitHub Releases: https://github.com/i-net-software/gradle-nuget-plugin/releases
96+

appveyor.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)