-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (123 loc) · 4.79 KB
/
release-plugin.yml
File metadata and controls
139 lines (123 loc) · 4.79 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
name: Release Plugin
on:
workflow_dispatch:
inputs:
plugin_id:
description: Canonical plugin id
required: true
type: string
bump:
description: SemVer bump to apply
required: true
default: auto
type: choice
options:
- auto
- patch
- minor
- major
version_override:
description: Explicit version override for backfills or exceptional releases
required: false
type: string
permissions:
contents: write
packages: write
concurrency:
group: release-${{ inputs.plugin_id }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Ensure workflow runs on default branch
if: github.ref_name != github.event.repository.default_branch
run: |
echo "Run releases from ${GITHUB_EVENT_REPOSITORY_DEFAULT_BRANCH:-the default branch} only."
exit 1
- name: Checkout plugins repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Load repository build settings
id: repo
run: python3 scripts/plugins_repo.py repo-settings --github-output "$GITHUB_OUTPUT"
- name: Set up Java 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ steps.repo.outputs.java_version }}
cache: maven
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
- name: Validate plugin repository structure
run: python3 scripts/plugins_repo.py validate
- name: Prepare release payload
id: release
shell: bash
run: |
args=(
python3 scripts/plugins_repo.py release
--plugin "${{ inputs.plugin_id }}"
--bump "${{ inputs.bump }}"
--github-output "$GITHUB_OUTPUT"
)
if [[ -n "${{ inputs.version_override }}" ]]; then
args+=(--version-override "${{ inputs.version_override }}")
fi
"${args[@]}"
- name: Configure Git author
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Publish GitHub Package
if: steps.release.outputs.skipped_existing_package != 'true'
run: |
mvn -B -ntp org.apache.maven.plugins:maven-deploy-plugin:3.1.4:deploy-file \
-DrepositoryId=github \
-Durl="https://maven.pkg.github.com/${GITHUB_REPOSITORY}" \
-Dfile="${{ steps.release.outputs.artifact_path }}" \
-DgroupId="me.golemcore.plugins" \
-DartifactId="${{ steps.release.outputs.artifact_id }}" \
-Dversion="${{ steps.release.outputs.version }}" \
-Dpackaging=jar \
-DgeneratePom=true \
-DretryFailedDeploymentCount=3
- name: Commit release metadata
if: steps.release.outputs.skipped_existing_package != 'true'
run: |
git add \
"${{ steps.release.outputs.pom_path }}" \
"${{ steps.release.outputs.plugin_yaml_path }}" \
"${{ steps.release.outputs.registry_index_path }}" \
"${{ steps.release.outputs.registry_version_path }}"
if ! git diff --cached --quiet; then
git commit -m "chore(release): ${{ steps.release.outputs.plugin_id }} v${{ steps.release.outputs.version }} [skip ci]"
fi
- name: Create Git tag
if: steps.release.outputs.skipped_existing_package != 'true'
run: git tag "${{ steps.release.outputs.tag_name }}"
- name: Push release commit and tag
if: steps.release.outputs.skipped_existing_package != 'true'
run: |
git push origin "HEAD:${{ github.event.repository.default_branch }}"
git push origin "${{ steps.release.outputs.tag_name }}"
- name: Report skipped publish
if: steps.release.outputs.skipped_existing_package == 'true'
run: |
echo "Skipping ${{ steps.release.outputs.plugin_id }} v${{ steps.release.outputs.version }}:"
echo "GitHub Package ${{ steps.release.outputs.artifact_id }}:${{ steps.release.outputs.version }} already exists."
- name: Publish GitHub Release
if: steps.release.outputs.skipped_existing_package != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release.outputs.tag_name }}
name: ${{ steps.release.outputs.release_name }}
generate_release_notes: true
files: |
${{ steps.release.outputs.artifact_path }}
${{ steps.release.outputs.registry_version_path }}