Repository navigation
174 lines (164 loc) · 7.04 KB
/
Copy pathbuild.yml
File metadata and controls
174 lines (164 loc) · 7.04 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
name: Build
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: write
env:
JAVA_VERSION: '17'
JAVA_DISTRIBUTION: temurin
jobs:
calc_ver:
runs-on: ubuntu-latest
outputs:
project_ver: ${{ steps.ver.outputs.project_ver }}
release_flag: ${{ steps.ver.outputs.release_flag }}
release_tag: ${{ steps.ver.outputs.release_tag }}
release_upload_url: ${{ steps.ver.outputs.release_upload_url }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: maven
- name: Auto-tag
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.repository == 'nbplugins/NetbeansPluginClaudeCodeGui'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
bash build-scripts/autotag.sh
- name: Calculate version
id: ver
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --prune --tags
# Release tag on current commit?
REL_TAG=$(git tag --points-at HEAD | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' || true)
if [[ -n "$REL_TAG" ]]; then
VER="$REL_TAG"
RELEASE=ON
# Create draft release if not yet exists
if ! gh release view "$REL_TAG" --json id -q .id &>/dev/null; then
NOTES=RELNOTES.md
[[ -f "$NOTES" ]] || echo "Release $VER" > "$NOTES"
gh release create "$REL_TAG" --draft --title "$VER" --notes-file "$NOTES"
fi
UPLOAD_URL=$(gh release view "$REL_TAG" --json uploadUrl -q .uploadUrl)
else
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-.*//')
MM=$(echo "$POM_VERSION" | cut -d. -f1-2)
MM_ESC="${MM//./\\.}"
LAST_REL=$(git tag | grep -E "^${MM_ESC}\.[0-9]+$" | sort -V | tail -1)
BASE_TAG=$(git tag | grep -E "^${MM_ESC}$" | sort -V | tail -1 || echo "")
if [[ -n "$LAST_REL" ]]; then
START=$(echo "$LAST_REL" | cut -d. -f3)
N=$(git rev-list "${LAST_REL}..HEAD" --count 2>/dev/null || echo "0")
VER="${MM}.$((START + N))"
elif [[ -n "$BASE_TAG" ]]; then
N=$(git rev-list "${BASE_TAG}..HEAD" --count 2>/dev/null || echo "0")
VER="${MM}.${N}"
else
VER="${MM}.0"
fi
RELEASE=OFF
UPLOAD_URL=""
REL_TAG=""
fi
echo "project_ver=$VER" >> $GITHUB_OUTPUT
echo "release_flag=$RELEASE" >> $GITHUB_OUTPUT
echo "release_tag=$REL_TAG" >> $GITHUB_OUTPUT
echo "release_upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
echo "Version: $VER (release=$RELEASE)"
build:
needs: calc_ver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Install pandoc
run: sudo apt-get install -y pandoc
- name: Set version
run: mvn versions:set -DnewVersion=${{ needs.calc_ver.outputs.project_ver }} --batch-mode
- name: Build and test
# xvfb-run provides a virtual display so Swing UI tests don't throw HeadlessException
run: xvfb-run mvn package --batch-mode
- name: Deploy to Maven Central (release only)
if: needs.calc_ver.outputs.release_flag == 'ON' && github.repository == 'nbplugins/NetbeansPluginClaudeCodeGui'
run: |
VERSION="${{ needs.calc_ver.outputs.project_ver }}"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
"https://repo1.maven.org/maven2/io/github/nbplugins/netbeans-plugin-claude-code-gui/$VERSION/netbeans-plugin-claude-code-gui-$VERSION.pom")
if [[ "$STATUS" == "200" ]]; then
echo "Version $VERSION already published to Maven Central, skipping."
else
if ! mvn deploy -P release -DskipTests --batch-mode; then
echo "::group::Maven Central bundle diagnostics"
echo "--- target/central-staging ---"
find target/central-staging -printf '%y %s %P\n' 2>/dev/null | sort -k3
echo "--- central-bundle.zip ---"
unzip -l target/central-publishing/central-bundle.zip 2>/dev/null || true
echo "--- target/*.asc, *.nbm, *.jar ---"
ls -la target/*.asc target/*.nbm target/*.jar 2>/dev/null || true
echo "::endgroup::"
exit 1
fi
fi
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Build documentation
run: |
VERSION=${{ needs.calc_ver.outputs.project_ver }}
pandoc \
--metadata title="Claude Code GUI for NetBeans — User Manual" \
--embed-resources --standalone \
--resource-path=docs \
-o "target/netbeans-plugin-claude-code-gui-${VERSION}-docs.html" \
docs/installation.md \
docs/user-manual.md
- name: Upload artifact and release asset
uses: nanoufo/action-upload-artifacts-and-release-assets@v2
with:
path: |
target/*.nbm
target/*-docs.html
upload-release-files: ${{ needs.calc_ver.outputs.release_flag == 'ON' }}
release-upload-url: ${{ needs.calc_ver.outputs.release_upload_url }}
release:
needs: [calc_ver, build]
if: needs.calc_ver.outputs.release_flag == 'ON' && github.repository == 'nbplugins/NetbeansPluginClaudeCodeGui'
runs-on: ubuntu-latest
steps:
- name: Publish GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REL_TAG="${{ needs.calc_ver.outputs.release_tag }}"
IS_DRAFT=$(gh release view "$REL_TAG" --json isDraft -q .isDraft 2>/dev/null || echo "true")
if [[ "$IS_DRAFT" == "false" ]]; then
echo "GitHub Release already published."
else
gh release edit "$REL_TAG" --draft=false --repo ${{ github.repository }}
fi