-
Notifications
You must be signed in to change notification settings - Fork 2
84 lines (81 loc) · 3.09 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
env:
TAG: v${{ github.event.inputs.version }}
JAR_NAME: deezer-api-${{ github.event.inputs.version }}-jar-with-dependencies.jar
JAR_PATH: target/deezer-api-${{ github.event.inputs.version }}-jar-with-dependencies.jar
jobs:
check_input:
runs-on: ubuntu-latest
steps:
- name: Check input
id: check_input
run: |
[[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "match=true" >> $GITHUB_OUTPUT || echo "match=false" >> $GITHUB_OUTPUT
- name: Validate input
if: steps.check_input.outputs.match != 'true'
run: |
echo "::error::Incorrect release version format: ${{ github.event.inputs.version }}. Expected format: x.y.z."
exit 1
release:
runs-on: ubuntu-latest
needs: [ check_input ]
steps:
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
cache: maven
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Central Repository
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: mvn -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} deploy
- name: Create Tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.TAG }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: ${{ env.TAG }}
draft: true
body: |
```xml
<dependency>
<groupId>com.github.yvasyliev</groupId>
<artifactId>deezer-api</artifactId>
<version>${{ github.event.inputs.version }}</version>
</dependency>
```
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.JAR_PATH }}
asset_name: ${{ env.JAR_NAME }}
asset_content_type: application/java-archive