Repository navigation
129 lines (127 loc) · 5.73 KB
/
Copy pathdeploy.yml
File metadata and controls
129 lines (127 loc) · 5.73 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish package to the Maven Central Repository
on:
release:
types: [published]
workflow_dispatch:
inputs:
target:
description: 'What to publish'
type: choice
options:
- all
- object-farm-api-only
default: all
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v6
with:
java-version: '11'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v6
- name: Restore gradle.properties
env:
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
shell: bash
run: |
echo "${GRADLE_PROPERTIES}" >> gradle.properties
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
# MIT-licensed provider. The default 'enhanced' bundles the proprietary gradle-actions-caching component.
cache-provider: basic
- name: Check object-farm-api changes
id: check-object-farm
if: github.event_name == 'release'
run: |
CURRENT_TAG=${GITHUB_REF_NAME}
# Walk the tag's own ancestry. Sorting every tag by version picks the highest tag in the
# repository, which for a maintenance release is a tag from a newer line (e.g. releasing
# 1.1.22 would compare against 1.2.0) and reports changes this release does not contain.
PREV_TAG=$(git describe --tags --abbrev=0 "${CURRENT_TAG}^" 2>/dev/null || true)
if [ -n "$PREV_TAG" ]; then
CHANGES=$(git diff --name-only "$PREV_TAG".."$CURRENT_TAG" -- object-farm-api/)
if [ -n "$CHANGES" ]; then
echo "publish=true" >> $GITHUB_OUTPUT
else
echo "publish=false" >> $GITHUB_OUTPUT
fi
else
echo "publish=true" >> $GITHUB_OUTPUT
fi
- name: Check already published versions
id: check-published
run: |
# Re-uploading a version that is already on Maven Central makes the Sonatype close
# transition fail with "Component ... already exists". That is what breaks a deploy
# re-run for an existing release, so skip publishing versions already published.
BASE=https://repo1.maven.org/maven2/com/navercorp/fixturemonkey
FM_VERSION=$(grep -m1 '^fixtureMonkeyVersion=' gradle.properties | cut -d= -f2 | tr -d '[:space:]')
OF_VERSION=$(grep -m1 '^objectFarmVersion=' gradle.properties | cut -d= -f2 | tr -d '[:space:]')
FM_CODE=$(curl -s -o /dev/null -w '%{http_code}' "${BASE}/fixture-monkey/${FM_VERSION}/")
OF_CODE=$(curl -s -o /dev/null -w '%{http_code}' "${BASE}/object-farm-api/${OF_VERSION}/")
echo "fixture-monkey ${FM_VERSION} -> HTTP ${FM_CODE}"
echo "object-farm-api ${OF_VERSION} -> HTTP ${OF_CODE}"
if [ "$FM_CODE" = "200" ]; then
echo "fixtureMonkeyPublished=true" >> $GITHUB_OUTPUT
else
echo "fixtureMonkeyPublished=false" >> $GITHUB_OUTPUT
fi
if [ "$OF_CODE" = "200" ]; then
echo "objectFarmApiPublished=true" >> $GITHUB_OUTPUT
else
echo "objectFarmApiPublished=false" >> $GITHUB_OUTPUT
fi
- name: Publish fixture-monkey modules
if: (github.event_name == 'release' || github.event.inputs.target == 'all') && steps.check-published.outputs.fixtureMonkeyPublished != 'true'
env:
OSSRH_USERNAME_TOKEN: ${{ secrets.OSSRHUSERNAME }}
OSSRH_PASSWORD_TOKEN: ${{ secrets.OSSRHPASSWORD }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x :object-farm-api:publishObjectFarmApiPublicationToSonatypeRepository
- name: Publish object-farm-api
if: ((github.event_name == 'release' && steps.check-object-farm.outputs.publish == 'true') || github.event_name == 'workflow_dispatch') && steps.check-published.outputs.objectFarmApiPublished != 'true'
env:
OSSRH_USERNAME_TOKEN: ${{ secrets.OSSRHUSERNAME }}
OSSRH_PASSWORD_TOKEN: ${{ secrets.OSSRHPASSWORD }}
run: ./gradlew :object-farm-api:publishObjectFarmApiPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
- name: Close milestone
if: github.event_name == 'release'
uses: Beakyn/gha-close-milestone@v1.1.1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository: ${{ github.repository }}
milestone-title: ${{ github.ref_name }}
- name: 'Get Previous tag'
id: previoustag
if: github.event_name == 'release'
uses: "WyriHaximus/github-action-get-previous-tag@v2"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: 'Get next minor version'
id: semvers
if: github.event_name == 'release'
uses: "WyriHaximus/github-action-next-semvers@v1"
with:
version: ${{ steps.previoustag.outputs.tag }}
- name: 'Create new milestone'
id: createmilestone
if: github.event_name == 'release'
uses: "WyriHaximus/github-action-create-milestone@v1"
with:
title: ${{ steps.semvers.outputs.patch }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"