-
-
Notifications
You must be signed in to change notification settings - Fork 216
85 lines (85 loc) · 2.98 KB
/
release.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
name: Release
on:
push:
tags:
- 'v*'
jobs:
#--------------------------------------------------
# Build and Tests the project
#--------------------------------------------------
tests:
name: tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 'Setup: checkout project'
uses: actions/checkout@v4
- name: 'Setup: environment'
id: setup
uses: ./.github/actions/setup
- name: 'Init: cache local Maven repository'
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Init: install Node.js packages'
run: npm ci
- name: 'Lint: check'
run: npm run lint:ci
- name: 'Test: run backend tests'
run: |
chmod +x mvnw
./mvnw clean verify
rm target/*-javadoc.jar target/*-sources.jar target/*-tests.jar
- name: 'Artifact: upload JAR'
uses: actions/upload-artifact@v4
with:
name: jhlite-jar
path: '${{ github.workspace }}/target/*.jar'
retention-days: 1
#--------------------------------------------------
# Release
#--------------------------------------------------
release:
if: startsWith(github.event.ref, 'refs/tags/v')
name: release
needs: tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 'Setup: checkout project'
uses: actions/checkout@v4
- name: 'Artifact: download JAR'
uses: actions/download-artifact@v4
with:
name: jhlite-jar
path: ./target/
- name: 'Release: get variables from artifact'
id: artifact_variables
run: |
ARTIFACT_PATHNAME=$(ls target/*.jar | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
ARTIFACT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "artifact_asset_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "artifact_asset_path=${ARTIFACT_PATHNAME}" >> $GITHUB_OUTPUT
echo "artifact_version=${ARTIFACT_VERSION}" >> $GITHUB_OUTPUT
- name: 'Release: publish release drafter'
uses: release-drafter/release-drafter@v5
id: release-drafter-final
with:
publish: true
tag: v${{ steps.artifact_variables.outputs.artifact_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Release: upload artifact'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release-drafter-final.outputs.upload_url }}
asset_name: ${{ steps.artifact_variables.outputs.artifact_asset_name }}
asset_path: ${{ steps.artifact_variables.outputs.artifact_asset_path }}
asset_content_type: application/java-archive