-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.77 KB
/
gradle-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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
name: CI
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: build
release:
if: startsWith(github.event.head_commit.message, 'Gradle Release Plugin') != true && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Publish
run: |
echo "setup ssh agent"
eval `ssh-agent -s`
echo "setup"
echo "$CI_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - >/dev/null
echo "added private ssh"
mkdir -p ~/.ssh
touch ~/.ssh/id_rsa.pub
echo "$CI_SSH_PUBLIC_KEY" | tr -d '\r' > ~/.ssh/id_rsa.pub
echo "added public ssh"
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" && git config user.name "github_action"
echo "git@github.com:${GITHUB_REPOSITORY}.git"
git remote set-url origin "git@github.com:${GITHUB_REPOSITORY}.git"
git fetch origin main && git checkout main
git remote -v
./gradlew release -Prelease.useAutomaticVersion=true
env:
CI_SSH_PUBLIC_KEY: ${{ secrets.CI_SSH_PUBLIC_KEY}}
CI_SSH_PRIVATE_KEY: ${{ secrets.CI_SSH_PRIVATE_KEY}}
ARTIFACTORY_USERNAME: ${{ github.actor }}
ARTIFACTORY_PASSCODE: ${{ secrets.GITHUB_TOKEN }}