-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (90 loc) · 3.93 KB
/
publish.yml
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
name: Publish
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
release_version:
runs-on: ubuntu-latest
if: github.repository == 'block/kotlin-formatter'
outputs:
version: ${{ steps.release_version.outputs.version }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Extract release version
id: release_version
run: |
VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2 | xargs)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Validate tag matches release version
run: |
if [[ "${{ github.ref_name }}" != "${{ steps.release_version.outputs.version }}" ]]; then
echo "Error: Tag '${{ github.ref_name }}' does not match expected version '${{ steps.release_version.outputs.version }}'."
exit 1
fi
publish:
needs: release_version
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_XYZ_BLOCK }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_XYZ_BLOCK }}
runs-on: ubuntu-latest
steps:
# Free disk space to avoid running into "No space left on device" errors
# when downloading multiple versions of IntelliJ for plugin verification
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
- name: Checkout the repo
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Execute buildHealth for build-logic
run: './gradlew -p build-logic buildHealth -s'
- name: Execute check
run: './gradlew check -s'
- name: Execute buildHealth for main project
run: './gradlew buildHealth -s'
- name: Publish artifacts
run: './gradlew publishToMavenCentral -s --no-configuration-cache'
- name: Prepare assets for Github Release
run: |
echo "Renaming assets to match Maven Central naming conventions."
mv kotlin-format/build/libs/kotlin-format-${{ needs.release_version.outputs.version }}-all.jar kotlin-format/build/libs/kotlin-formatter-${{ needs.release_version.outputs.version }}-all.jar
mv kotlin-format/build/distributions/kotlin-format-shadow-${{ needs.release_version.outputs.version }}.zip kotlin-format/build/distributions/kotlin-formatter-dist-${{ needs.release_version.outputs.version }}.zip
- name: Extract release notes
id: release_notes
uses: ffurrer2/extract-release-notes@v2
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release_version.outputs.version }}
name: ${{ needs.release_version.outputs.version }}
body: |
${{ steps.release_notes.outputs.release_notes }}
draft: false
prerelease: false
files: |
kotlin-format/build/libs/kotlin-formatter-${{ needs.release_version.outputs.version }}-all.jar
kotlin-format/build/distributions/kotlin-formatter-dist-${{ needs.release_version.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Idea Plugin
run: |
export IJ_PLUGIN_VERSION="${{ needs.release_version.outputs.version }}"
echo "IJ_PLUGIN_VERSION=$IJ_PLUGIN_VERSION" >> $GITHUB_ENV
./gradlew idea-plugin:publishPlugin
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_SQUARE_PLUGINS }}