kpm_release #32
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |