update kotlin-stdlib to fix security warning
[yosql.git] / .github / workflows / release.yml
blob9b16bb79a90fac7db63cb03621f0f9d0f43baecd
1 name: Perform Release
2 on:
3   schedule:
4     - cron:  25 3 * * WED
5   workflow_dispatch:
6 env:
7   JAVA_VERSION: 17
8   JAVA_PACKAGE: jdk
9   JAVA_ARCH: x64
10   JAVA_DISTRO: temurin
11   PROJECT_URL: yosql.projects.metio.wtf
12 jobs:
13   prepare:
14     name: Prepare Release
15     runs-on: ubuntu-latest
16     outputs:
17       commit_count: ${{ steps.commits.outputs.count }}
18       release_version: ${{ steps.release.outputs.version }}
19       previous_version: ${{ steps.previous.outputs.version }}
20       changelog: ${{ steps.changelog.outputs.content }}
21       release_url: ${{ steps.create_release.outputs.upload_url }}
22     steps:
23       - id: checkout
24         name: Clone Git Repository
25         uses: actions/checkout@v3
26         with:
27           fetch-depth: 0 # required in order to get all tags
28       - id: commits
29         name: Count Commits
30         run: echo "::set-output name=count::$(git rev-list --count HEAD --since='last Wednesday' -- yosql-codegen yosql-converters yosql-dao yosql-internals yosql-logging yosql-models yosql-testing yosql-tooling)"
31       - id: release
32         name: Create Release Version
33         if: steps.commits.outputs.count > 0
34         run: echo "::set-output name=version::$(date +'%Y.%-m.%-d')"
35       - id: previous
36         name: Get Last Release
37         if: steps.commits.outputs.count > 0
38         run: echo "::set-output name=version::$(git describe --abbrev=0 --tags)"
39       - id: generate_changelog
40         name: Generate Changelog
41         if: steps.commits.outputs.count > 0
42         uses: heinrichreimer/github-changelog-generator-action@v2.3
43         with:
44           token: ${{ secrets.GITHUB_TOKEN }}
45           unreleased: true
46           issues: true
47           issuesWoLabels: true
48           pullRequests: true
49           prWoLabels: true
50           filterByMilestone: false
51           futureRelease: ${{ steps.release.outputs.version }}
52           sinceTag: ${{ steps.previous.outputs.version }}
53           stripGeneratorNotice: true
54           stripHeaders: true
55       - name: Check Changelog Existence
56         id: check_changelog
57         uses: andstor/file-existence-action@v1.1.0
58         with:
59           files: CHANGELOG.md
60       - name: Create Empty Changelog
61         id: empty_changelog
62         uses: 1arp/create-a-file-action@0.2
63         if: steps.check_changelog.outputs.files_exists == 'false'
64         with:
65           file: CHANGELOG.md
66           content: |
67             no user facing changes
68       - name: Read Changelog
69         id: changelog
70         uses: juliangruber/read-file-action@v1
71         with:
72           path: ./CHANGELOG.md
73       - id: create_release
74         name: Create Release
75         if: steps.commits.outputs.count > 0
76         uses: actions/create-release@v1.1.4
77         env:
78           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79         with:
80           tag_name: ${{ steps.release.outputs.version }}
81           release_name: ${{ steps.release.outputs.version }}
82           draft: false
83           prerelease: false
84           body: |
85             # YoSQL
86             Write more SQL! Take a look at the [website](https://${{ env.PROJECT_URL }}/) for detailed information. **This release requires at least Java ${{ env.JAVA_VERSION }}** at build time.
87             ## Changes
88             ${{ steps.changelog.outputs.content }}
89   deploy:
90     name: Deploy Artifacts
91     runs-on: ubuntu-latest
92     needs: prepare
93     steps:
94       - id: checkout
95         name: Clone Git Repository
96         uses: actions/checkout@v3
97         if: needs.prepare.outputs.commit_count > 0
98       - id: java
99         name: Setup Java
100         uses: actions/setup-java@v3
101         if: needs.prepare.outputs.commit_count > 0
102         with:
103           java-version: ${{ env.JAVA_VERSION }}
104           java-package: ${{ env.JAVA_PACKAGE }}
105           architecture: ${{ env.JAVA_ARCH }}
106           distribution: ${{ env.JAVA_DISTRO }}
107           server-id: ossrh
108           server-username: MAVEN_CENTRAL_USERNAME
109           server-password: MAVEN_CENTRAL_TOKEN
110       - id: cache
111         name: Cache Maven Repository
112         uses: actions/cache@v3
113         if: needs.prepare.outputs.commit_count > 0
114         with:
115           path: ~/.m2/repository
116           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
117           restore-keys: |
118             ${{ runner.os }}-maven-
119       - id: gpg
120         name: GPG Key
121         run: echo "${{ secrets.GPG_SECRET_KEY_BASE64 }}" | base64 --decode > $GITHUB_WORKSPACE/signing.key.asc
122       - name: Set release version
123         run: mvn --batch-mode versions:set -DnewVersion=${{ needs.prepare.outputs.release_version }} -DgenerateBackupPoms=false
124         if: needs.prepare.outputs.commit_count > 0
125       - id: deploy-maven
126         name: Deploy Maven Tooling
127         run: MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" mvn --batch-mode --activate-profiles release --projects yosql-tooling/yosql-tooling-maven --also-make install deploy -Dpgp.secretkey=keyfile:$GITHUB_WORKSPACE/signing.key.asc -Dpgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }}
128         if: needs.prepare.outputs.commit_count > 0
129         env:
130           MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
131           MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
132       - id: build-gradle
133         name: Build Gradle Tooling
134         run: cd ./yosql-examples/yosql-examples-gradle/ && ./gradlew build -Pversion=${{ needs.prepare.outputs.release_version }}
135         if: needs.prepare.outputs.commit_count > 0
136       - id: deploy-gradle
137         name: Deploy Gradle Tooling
138         run: cd ./yosql-tooling/yosql-tooling-gradle/ && ./gradlew publishPlugins -Pversion=${{ needs.prepare.outputs.release_version }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
139         if: needs.prepare.outputs.commit_count > 0
140   benchmarks:
141     name: Run Benchmarks
142     runs-on: ubuntu-latest
143     needs: [prepare, deploy]
144     strategy:
145       matrix:
146         benchmark: [codegen, jdbc]
147     steps:
148       - id: checkout
149         name: Clone Git Repository
150         uses: actions/checkout@v3
151         if: needs.prepare.outputs.commit_count > 0
152       - id: java
153         name: Setup Java
154         uses: actions/setup-java@v3
155         if: needs.prepare.outputs.commit_count > 0
156         with:
157           java-version: ${{ env.JAVA_VERSION }}
158           java-package: ${{ env.JAVA_PACKAGE }}
159           architecture: ${{ env.JAVA_ARCH }}
160           distribution: ${{ env.JAVA_DISTRO }}
161       - id: cache
162         name: Cache Maven Repository
163         uses: actions/cache@v3
164         if: needs.prepare.outputs.commit_count > 0
165         with:
166           path: ~/.m2/repository
167           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
168           restore-keys: |
169             ${{ runner.os }}-maven-
170       - id: run-benchmark
171         name: Run Benchmark [${{ matrix.benchmark }}]
172         run: mvn --batch-mode --projects yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }} --also-make --activate-profiles benchmarks verify -Dorg.slf4j.simpleLogger.log.yosql=warn -DskipTests 2>&1 1> build.log
173         if: needs.prepare.outputs.commit_count > 0
174       - id: upload-benchmark
175         name: Upload Benchmark Results
176         uses: actions/upload-artifact@v3
177         if: needs.prepare.outputs.commit_count > 0
178         with:
179           name: benchmark-${{ matrix.benchmark }}
180           path: ./yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }}/target/benchmark/yosql-benchmarks-${{ matrix.benchmark }}.json
181   website:
182     name: Update Website
183     runs-on: ubuntu-latest
184     needs: [prepare, benchmarks]
185     steps:
186       - id: checkout
187         name: Clone Git Repository
188         uses: actions/checkout@v3
189         if: needs.prepare.outputs.commit_count > 0
190       - id: java
191         name: Setup Java
192         uses: actions/setup-java@v3
193         if: needs.prepare.outputs.commit_count > 0
194         with:
195           java-version: ${{ env.JAVA_VERSION }}
196           java-package: ${{ env.JAVA_PACKAGE }}
197           architecture: ${{ env.JAVA_ARCH }}
198           distribution: ${{ env.JAVA_DISTRO }}
199       - id: cache
200         name: Cache Maven Repository
201         uses: actions/cache@v3
202         if: needs.prepare.outputs.commit_count > 0
203         with:
204           path: ~/.m2/repository
205           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
206           restore-keys: |
207             ${{ runner.os }}-maven-
208       - id: download
209         name: Download Benchmarks Results
210         uses: actions/download-artifact@v3
211         if: needs.prepare.outputs.commit_count > 0
212       - id: copy-codegen-results
213         name: Copy Codegen Results
214         run: cp --force ./benchmark-codegen/yosql-benchmarks-codegen.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-codegen-${{ needs.prepare.outputs.release_version }}.json
215         if: needs.prepare.outputs.commit_count > 0
216       - id: replace-codegen-results
217         name: Replace CURRENT Codegen Results
218         run: cp --force ./benchmark-codegen/yosql-benchmarks-codegen.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-codegen-CURRENT.json
219         if: needs.prepare.outputs.commit_count > 0
220       - id: copy-jdbc-results
221         name: Copy JDBC Results
222         run: cp --force ./benchmark-dao/yosql-benchmarks-dao.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-dao-${{ needs.prepare.outputs.release_version }}.json
223         if: needs.prepare.outputs.commit_count > 0
224       - id: replace-jdbc-results
225         name: Replace CURRENT JDBC Results
226         run: cp --force ./benchmark-dao/yosql-benchmarks-dao.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-dao-CURRENT.json
227         if: needs.prepare.outputs.commit_count > 0
228       - id: push
229         name: Push Changes
230         uses: stefanzweifel/git-auto-commit-action@v4
231         if: needs.prepare.outputs.commit_count > 0
232         with:
233           commit_message: Update website data for ${{ needs.prepare.outputs.release_version }}
234           file_pattern: yosql-website/*.json
235   announce:
236     name: Send Announcements
237     needs: [prepare, website]
238     runs-on: ubuntu-latest
239     steps:
240       - id: email
241         name: Send Mail
242         uses: dawidd6/action-send-mail@v3
243         if: needs.prepare.outputs.commit_count > 0
244         with:
245           server_address: ${{ secrets.MAIL_SERVER }}
246           server_port: ${{ secrets.MAIL_PORT }}
247           username: ${{ secrets.MAIL_USERNAME }}
248           password: ${{ secrets.MAIL_PASSWORD }}
249           to: ${{ secrets.MAIL_TO }}
250           from: ${{ secrets.MAIL_SENDER }}
251           subject: release ${{ needs.prepare.outputs.release_version }}
252           body: See https://github.com/metio/yosql/releases/tag/${{ needs.prepare.outputs.release_version }} for details.
253       - id: matrix
254         name: Send Matrix Message
255         uses: s3krit/matrix-message-action@v0.0.3
256         if: needs.prepare.outputs.commit_count > 0
257         with:
258           access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
259           room_id: ${{ secrets.MATRIX_ROOM_ID }}
260           server: ${{ secrets.MATRIX_SERVER }}
261           message: release ${{ needs.prepare.outputs.release_version }} published - see https://github.com/metio/yosql/releases/tag/${{ needs.prepare.outputs.release_version }} for details