Skip to content

Commit

Permalink
kpm: automated releases
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Alexandre Meyer <[email protected]>
  • Loading branch information
pierre committed Mar 22, 2021
1 parent 3477b4b commit 1b7d32c
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 40 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/kpm_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: kpm_release

on:
workflow_dispatch:
inputs:
target_version:
description: 'Target version: given version number [x.x.x]'
required: true
default: '0.x.0'

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-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup git user
env:
BUILD_USER: ${{ secrets.BUILD_USER }}
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Kill Bill core team"
git config --global url."https://${BUILD_USER}:${BUILD_TOKEN}@github.com/".insteadOf "[email protected]:"
- name: Configure settings.xml for release
uses: actions/setup-java@v1
with:
java-version: 8
server-id: ossrh-releases
server-username: OSSRH_USER
server-password: OSSRH_PASS
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- 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 TRAVELING_RUBY_VERSION in tasks/package.rake
rvm install 2.2.2 --binary
rvm --default use 2.2.2
- name: Set up Bundler
run: |
source $HOME/.rvm/scripts/rvm
gem install bundler --no-document
- name: Download Ruby dependencies
run: |
source $HOME/.rvm/scripts/rvm
cd kpm
bundle install
- name: Tag repository
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
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
- name: Build self-contained packages
run: |
source $HOME/.rvm/scripts/rvm
cd kpm
$GITHUB_WORKSPACE/killbill-cloud/bin/retry bundle exec rake package
- name: Push to Maven Central
env:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
VERSION: ${{ github.event.inputs.target_version }}
run: |
cd kpm
mvn ${MAVEN_FLAGS} -Psonatype-oss-release deploy
21 changes: 21 additions & 0 deletions bin/retry
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -euo pipefail

x() {
echo "+ $*" >&2
"$@"
}

retry_delay_seconds=10

i="0"
while [ $i -lt 4 ]
do
x "$@" && exit 0
sleep "${retry_delay_seconds}"
i=$[$i+1]
done

echo "$0: retrying [$*] timed out" >&2
exit 1
1 change: 1 addition & 0 deletions kpm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ kpm-*-osx.tar.gz
traveling-ruby-*.tar.gz
*.asc
.rakeTasks
pom.xml.versionsBackup
1 change: 1 addition & 0 deletions kpm/kpm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Gem::Specification.new do |s|
s.add_dependency 'rubyzip', '~>1.2.0'
s.add_dependency 'thor', '~> 0.19.1'

s.add_development_dependency 'gem-release', '~> 2.2'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rspec', '~> 3.9'
s.add_development_dependency 'rubocop', '~> 0.88.0' if RUBY_VERSION >= '2.4'
Expand Down
251 changes: 211 additions & 40 deletions kpm/pom.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2014-2017 The Billing Project, LLC
~
~ The Billing Project licenses this file to you under the Apache License, version 2.0
~ (the "License"); you may not use this file except in compliance with the
~ License. You may obtain a copy of the License at:
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ License for the specific language governing permissions and limitations
~ under the License.
-->

~ Copyright 2010-2014 Ning, Inc.
~ Copyright 2014-2020 Groupon, Inc
~ Copyright 2020-2020 Equinix, Inc
~ Copyright 2014-2020 The Billing Project, LLC
~
~ The Billing Project licenses this file to you under the Apache License, version 2.0
~ (the "License"); you may not use this file except in compliance with the
~ License. You may obtain a copy of the License at:
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ License for the specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.kill-bill.billing.installer</groupId>
<artifactId>kpm</artifactId>
<packaging>pom</packaging>
<version>0.9.0</version>
<name>KPM</name>
<url>http://github.com/killbill/killbill-cloud</url>
<description>KPM: the Kill Bill Package Manager</description>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/killbill/killbill-cloud.git</connection>
<url>https://github.com/killbill/killbill-cloud/</url>
<developerConnection>scm:git:[email protected]:killbill/killbill-cloud.git</developerConnection>
</scm>
<modelVersion>4.0.0</modelVersion>
<groupId>org.kill-bill.billing.installer</groupId>
<artifactId>kpm</artifactId>
<version>0.9.0</version>
<packaging>pom</packaging>
<name>KPM</name>
<description>KPM: the Kill Bill Package Manager</description>
<url>http://github.com/killbill/killbill-cloud</url>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>pierre</id>
<name>Pierre-Alexandre Meyer</name>
<email>[email protected]</email>
</developer>
<developer>
<id>stephane</id>
<name>Stephane Brossier</name>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>Kill Bill users</name>
<subscribe>[email protected]</subscribe>
<unsubscribe>[email protected]</unsubscribe>
<post>[email protected]</post>
<archive>http://groups.google.com/group/killbilling-users</archive>
</mailingList>
</mailingLists>
<scm>
<connection>scm:git:git://github.com/killbill/killbill-cloud.git</connection>
<url>https://github.com/killbill/killbill-cloud/</url>
<developerConnection>scm:git:[email protected]:killbill/killbill-cloud.git</developerConnection>
</scm>
<issueManagement>
<system>Github</system>
<url>https://github.com/killbill/killbill-cloud/issues</url>
</issueManagement>
<distributionManagement>
<repository>
<id>${repository.release.id}</id>
<name>${repository.release.name}</name>
<url>${repository.release.url}</url>
</repository>
<snapshotRepository>
<id>${repository.snapshot.id}</id>
<name>${repository.snapshot.name}</name>
<url>${repository.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<properties>
<repository.release.id>sonatype-nexus-staging</repository.release.id>
<repository.release.name>Nexus Release Repository</repository.release.name>
<repository.release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</repository.release.url>
<repository.snapshot.id>sonatype-nexus-snapshots</repository.snapshot.id>
<repository.snapshot.name>Sonatype Nexus Snapshots</repository.snapshot.name>
<repository.snapshot.url>https://oss.sonatype.org/content/repositories/snapshots/</repository.snapshot.url>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-resources</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testResources</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>kpm-${project.version}-linux-x86.tar.gz</file>
<type>tar.gz</type>
<classifier>linux-x86</classifier>
</artifact>
<artifact>
<file>kpm-${project.version}-linux-x86_64.tar.gz</file>
<type>tar.gz</type>
<classifier>linux-x86_64</classifier>
</artifact>
<artifact>
<file>kpm-${project.version}-osx.tar.gz</file>
<type>tar.gz</type>
<classifier>osx</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- Prevent `gpg` from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh-releases</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
<keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 1b7d32c

Please sign in to comment.