-
-
Notifications
You must be signed in to change notification settings - Fork 87
151 lines (148 loc) · 5.64 KB
/
kpm_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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: kpm_release
on:
workflow_dispatch:
inputs:
target_version:
description: 'Target version: given version number [x.x.x]'
required: false
default: ''
type: string
perform_version:
description: 'tag to (re-)perform (in case of deploy failure)'
required: false
default: ''
type: string
release_kpm:
description: 'whether the release the kpm gem'
required: true
default: true
type: boolean
snapshot_only:
description: 'whether to push to Sonatype snapshots'
required: true
default: false
type: boolean
env:
MAVEN_FLAGS: "-B --no-transfer-progress"
MAVEN_OPTS: "-Xmx2G -XX:+ExitOnOutOfMemoryError -Dmaven.wagon.rto=60000 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3"
jobs:
kpm_release:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
if: github.event.inputs.perform_version == ''
uses: actions/checkout@v3.0.2
- name: Checkout full repository
if: github.event.inputs.perform_version != ''
uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.inputs.perform_version }}
- name: Setup git user
env:
BUILD_USER: ${{ secrets.BUILD_USER }}
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: |
git config --global user.email "contact@killbill.io"
git config --global user.name "Kill Bill core team"
git config --global url."https://${BUILD_USER}:${BUILD_TOKEN}@github.com/".insteadOf "git@github.com:"
- name: Configure settings.xml for release
uses: actions/setup-java@v3.3.0
if: github.event.inputs.snapshot_only == 'false'
with:
java-version: 11
distribution: temurin
server-id: ossrh-releases
server-username: OSSRH_USER
server-password: OSSRH_PASS
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Configure settings.xml for snapshots
uses: actions/setup-java@v3.3.0
if: github.event.inputs.snapshot_only == 'true'
with:
java-version: 11
distribution: temurin
server-id: sonatype-nexus-snapshots
server-username: OSSRH_USER
server-password: OSSRH_PASS
- name: Install packages
run: |
sudo apt-get -yq update
sudo apt-get -y install libgdbm5 libgdbm-dev libncurses5-dev libyaml-dev libssl1.0-dev
- name: Set up RVM
run: |
curl -sSL https://get.rvm.io | bash
- name: Set up Ruby
run: |
source $HOME/.rvm/scripts/rvm
# See HOMEBREW_PORTABLE_RUBY_VERSION in tasks/package.rake
ruby_version=$(sed -n "s/HOMEBREW_PORTABLE_RUBY_VERSION\s*=\s*'\([0-9.]*\).*'/\1/p" kpm/tasks/package.rake)
rvm install $ruby_version --binary
rvm --default use $ruby_version
- name: Set up Bundler
run: |
source $HOME/.rvm/scripts/rvm
gem install bundler -v 1.17.3 --no-document
- name: Download Ruby dependencies
run: |
source $HOME/.rvm/scripts/rvm
cd kpm
bundle install
- name: Tag repository
if: github.event.inputs.perform_version == '' && github.event.inputs.release_kpm == 'true'
run: |
source $HOME/.rvm/scripts/rvm
cd kpm
mvn versions:set -DnewVersion=${{ github.event.inputs.target_version }}
git add pom.xml
git commit -m "kpm: update pom.xml for release"
bundle exec gem bump -c -p -t -v ${{ github.event.inputs.target_version }}
- name: Release Gem
if: github.event.inputs.perform_version == '' && github.event.inputs.release_kpm == 'true'
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
source $HOME/.rvm/scripts/rvm
mkdir -p ~/.gem
cat << EOF > ~/.gem/credentials
---
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
cd kpm
bundle install
bundle exec gem release
rm -f ~/.gem/credentials
# Needs to happen before building the .tar.gz to get the right directory name
- name: Set new SNAPSHOT version
if: github.event.inputs.snapshot_only == 'true'
run: |
cd kpm
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# Need a -SNAPSHOT suffix for Sonatype
snapshot_version="${current_version}-$(git rev-parse --short "$GITHUB_SHA")-SNAPSHOT"
mvn versions:set -DnewVersion=${snapshot_version}
for i in $(ls *.tar.gz); do mv $i $(echo $i | sed s/$current_version/$snapshot_version/); done
echo "::notice ::Version is ${snapshot_version}"
- name: Build self-contained packages
run: |
source $HOME/.rvm/scripts/rvm
cd kpm
../bin/retry bundle exec rake package
- name: Push to Maven Central
if: github.event.inputs.snapshot_only == 'false'
env:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
cd kpm
mvn ${MAVEN_FLAGS} -Psonatype-oss-release deploy
- name: Push to Sonatype snapshots
if: github.event.inputs.snapshot_only == 'true'
env:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
run: |
cd kpm
mvn ${MAVEN_FLAGS} deploy