Publish from GitHub Actions (#30288)

* Publish from GitHub Actions

* Break out instructions into release train issue template
This commit is contained in:
Arnout Engelen 2021-06-08 09:05:16 +02:00 committed by GitHub
parent 2c524f110f
commit 39b4a5c57a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 129 additions and 293 deletions

58
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,58 @@
name: Publish
on:
push:
branches:
- master
tags: ["*"]
jobs:
sbt:
name: sbt publish
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0
- name: Set up JDK 11
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11.0-9
- name: Publish
run: |-
sbt +mimaReportBinaryIssues
sbt whitesourceCheckPolicies
sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
# TODO publish gradle from here as well
documentation:
name: Documentation
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0
- name: Set up JDK 11
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11.0-9
- name: Publish
run: |-
eval "$(ssh-agent -s)"
echo $SCP_SECRET | base64 -d > /tmp/id_rsa
chmod 600 /tmp/id_rsa
ssh-add /tmp/id_rsa
# using Scala 2.13 here to avoid the infamous problem with missing AskSupport in classpath
sbt -Dakka.build.scalaVersion=2.13.0 -Dakka.genjavadoc.enabled=true publishRsync
env:
SCP_SECRET: ${{ secrets.SCP_SECRET }}

View file

@ -12,7 +12,7 @@ For resilience, we adopt the "Let it crash" model which the telecom industry has
Actors also provide the abstraction for transparent distribution and the basis for truly scalable and fault-tolerant applications.
Learn more at [akka.io](http://akka.io/).
Learn more at [akka.io](https://akka.io/).
Reference Documentation
-----------------------

View file

@ -1,5 +1,13 @@
# Releasing
Create a new issue from the [Release Train Issue Template](scripts/release-train-issue-template.md):
```
$ sh ./scripts/create-release-issue.sh 0.x.y
```
# Manually
## Prerequisites
### JDK 8 and JDK 11

View file

@ -16,7 +16,6 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.27")
// sbt-osgi 0.9.6 is available but breaks populating akka-protobuf-v3
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")
@ -26,5 +25,6 @@ addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.18")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.hpe.sbt" % "sbt-pull-request-validator" % "1.0.0")
addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.25")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.lightbend.sbt" % "sbt-publish-rsync" % "0.2")

View file

@ -1,290 +0,0 @@
#!/usr/bin/env bash
#
# Release script for Akka.
#
# ATTENTION: This script involves calling `git clean -fxd` which will remove all untracked
# files from your working directory (including IDE settings).
#
# Prerequisites and Installation Instructions
#
# 1) You must be able to sign the artifacts with PGP
#
# 1.1) If you don't have PGP and a PGP key
# On OS X from othe command line:
# shell> brew install gnupg
# shell> gpg --gen-key
#
# On OS X the following should be added to ~/.bash_profile
# GPG_TTY=$(tty)
# export GPG_TTY
#
# Default values for the key type and 2048 bits is OK.
# Make sure to use the email address that you will use later to register
# with Sonatype.
#
# 1.2) Check that signing works
# From inside sbt do the following
# sbt> publishLocalSigned
# It should should ask you for your pass phrase, and create .asc files for
# all artifacts
#
# 1.3) Publish your key to a server that Sonatype use
# From the command line:
# shell> gpg --keyserver hkp://pool.sks-keyservers.net/ --send-keys <your key id>
# To find out your key id do this from the command line:
# shell> gpg --list-keys
# pub 2048/<your key id> ...
# You can verify the existence of your key here, if you don't trust your tool:
# https://sks-keyservers.net/i/#extract
#
# 2) You must have publishing rights to oss.sonatype.org
#
# 2.1) Register with oss.sonatype.org by only following the instructions under
# sign up here https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
# Use the same email address as you used for the pgp key.
#
# 2.2) Ask Jonas who is the original creator of this ticket https://issues.sonatype.org/browse/OSSRH-3097
# to add a comment that says that your username (not your full name) should
# have publish access to that project. There is manual administration of
# the ticket at Sonatype, so it could take a little while.
#
# 2.3) Add your credentials to sbt by adding a global.sbt file in your sbt home
# directory containing the following.
# credentials += Credentials("Sonatype Nexus Repository Manager",
# "oss.sonatype.org",
# "<your username>",
# "<your password>")
#
# 3) You must have access to gustav.akka.io
# Please note that gustav.akka.io is the same as repo.akka.io,
# but the latter domain is pointed at cloudflare so one could not ssh into it.
#
# 3.1) Ask someone in the team for login information for the akkarepo user.
#
# 3.2) Install your public ssh key to avoid typing in your password.
# From the command line:
# shell> cat ~/.ssh/id_rsa.pub | ssh akkarepo@gustav.akka.io "cat >> ~/.ssh/authorized_keys"
#
# 3.3) Also make it available for publishing snapshots.
# From the command line:
# shell> cp ~/.ssh/id_rsa ~/.ssh/id_rsa_gustav.pem
# shell> ssh-keygen -p -f ~/.ssh/id_rsa_gustav.pem -m pem
#
# 4) Have access to github.com/akka/akka. This should be a given.
#
# Now you should be all set to run the script
#
# Run the script:
#
# shell> project/scripts/release
#
# The artifacts published to oss.sonatype.org need to be released by following the
# instructions under release here
# https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
# defaults
declare -r default_server="akkarepo@gustav.akka.io"
declare -r default_path="www"
# settings
declare release_server=${default_server}
declare release_path=${default_path}
# get the source location for this script; handles symlinks
function get_script_path {
local source="${BASH_SOURCE[0]}"
while [ -h "${source}" ] ; do
source="$(readlink "${source}")";
done
echo ${source}
}
# path, name, and dir for this script
declare -r script_path=$(get_script_path)
declare -r script_name=$(basename "${script_path}")
declare -r script_dir="$(cd -P "$(dirname "${script_path}")" && pwd)"
# print usage info
function usage {
cat <<EOM
Dry run is be default.
Usage: ${script_name} [options]
-h | --help Print this usage message
-s | --server SERVER Set the release server (default ${default_server})
-p | --path PATH Set the path on the release server (default ${default_path})
EOM
}
# echo a log message
function echolog {
echo "[${script_name}] $@"
}
# echo an error message
function echoerr {
echo "[${script_name}] $@" 1>&2
}
# fail the script with an error message
function fail {
echoerr "$@"
exit 1
}
# process options and set flags
while true; do
case "$1" in
-h | --help ) usage; exit 1 ;;
-s | --server ) release_server=$2; shift 2 ;;
-p | --path ) release_path=$2; shift 2 ;;
* ) break ;;
esac
done
declare -r publish_path="${release_server}:${release_path}"
JAVA_VERSION=`java -version 2>&1 | grep -E "java version|openjdk version" | cut -d '"' -f2 | cut -d '.' -f1`
[[ $JAVA_VERSION -ge 11 ]] || fail "Java version is not at least 11"
# check for a git command
type -P git &> /dev/null || fail "git command not found"
# check for an sbt command
type -P sbt &> /dev/null || fail "sbt command not found"
# check for an rsync command
type -P rsync &> /dev/null || fail "rsync command not found"
# check for a tar command
type -P tar &> /dev/null || fail "tar command not found"
# get the current project version from sbt
# a little messy as the ansi escape codes are included
function get_current_version {
local result=$(sbt version | grep -v warn | grep -v "coordinated shutdown" | tail -1 | cut -f2)
# remove ansi escape code from end
local code0=$(echo -e "\033[0m")
echo ${result%$code0}
}
# check that we have a clean status
[[ -z "$(git status --porcelain)" ]] || {
git status
fail "There are uncommitted changes - please commit before releasing"
}
(read -p "The working directory will now be cleaned from all non-tracked files. Are you sure you want this? " x; test "$x" = yes) || fail "bailing out"
git clean -fxd || fail "cannot git clean -fxd"
# try to run a cleanup command - these shouldn't actually fail
function safely {
"$@" || fail "Failed to clean up release - please check current state"
}
# perform a clean up when a failure has occurred
function git_cleanup {
echoerr "Cleaning up..."
safely git reset --hard
safely git clean -f
}
# clean up and fail the script with an error message
function bail_out {
echoerr "Bailing out!"
git_cleanup
echoerr "Cleaned up failed release"
fail "$@"
}
# bail out for signals
function signal_bail_out {
echoerr "Interrupted by signal"
bail_out "Received signal to stop release"
}
# bail out on signals
trap signal_bail_out SIGHUP SIGINT SIGTERM
# try to run a command or otherwise bail out
function try {
"$@" || bail_out "Failed to create release"
}
declare -r version=$(get_current_version)
if [ ${#version} -gt 6 ]; then
fail "Version [$version] is too long to be a regular release, have you created a tag?"
fi
echolog "Creating release ${version}..."
echolog "Publishing to ${publish_path}"
# try ssh'ing to the release server
echolog "Checking ssh connection to ${release_server}"
try ssh -t ${release_server} echo "Successfully contacted release server."
# start clean
try sbt clean
echolog "Running migration manager report..."
try sbt $RELEASE_OPT +mimaReportBinaryIssues
echolog "Finished migration manager report"
# build the release
echolog "Building the release..."
RELEASE_OPT="-Dakka.genjavadoc.enabled=true -Dpublish.maven.central=true"
# Release artifacts
try sbt $RELEASE_OPT +publishSigned
echolog "Successfully released artifacts"
try sbt $RELEASE_OPT whitesourceCheckPolicies
# use a special failure from now on
function arrgh {
cat 1>&2 <<EOM
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Release failed while pushing to servers!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOM
fail "Could not complete release - please check current state"
}
# try running a pushing command or otherwise fail
function important {
"$@" || arrgh
}
# new interrupted bail out for signals
function arrgh_interrupt {
echoerr "Interrupted by signal"
arrgh
}
# new exit on signals
trap arrgh_interrupt SIGHUP SIGINT SIGTERM
# push the commits and tags to git origin
echolog "Pushing to git origin..."
important git push origin --tags
echolog "Building docs and pushing to the server..."
for section in docs api japi; do
important ssh ${release_server} "cd ${release_path}/${section}/akka; git add .; git commit -m 'before publishing version $version $section'; true"
done
# using Scala 2.13 here to avoid the infamous problem with missing AskSupport in classpath
important sbt -Dakka.build.scalaVersion=2.13.0 $RELEASE_OPT publishRsync
for section in docs api japi; do
important ssh ${release_server} "cd ${release_path}/${section}/akka; git add .; git commit -m 'publish version $version $section'"
done
echolog "*****"
echolog "Do not forget to update https://github.com/akka/akka.io/blob/master/versions.json !"
echolog "*****"
echolog "Successfully created release ${version}"

View file

@ -0,0 +1,10 @@
#!/bin/bash
VERSION=$1
if [ -z $VERSION ]
then
echo specify the version name to be released, eg. 1.0.0
else
sed -e 's/\$VERSION\$/'$VERSION'/g' scripts/release-train-issue-template$2.md > /tmp/release-$VERSION.md
echo Created $(hub issue create -F /tmp/release-$VERSION.md --browse)
fi

View file

@ -0,0 +1,50 @@
Release Akka $VERSION$
### Before the release
- [ ] Make sure all important / big PRs have been merged by now
- [ ] Create a news item draft PR on [akka.github.com](https://github.com/akka/akka.github.com), using the milestone
- [ ] Make sure to update `versions.json` in it
### Cutting the release
- [ ] Make sure any running [actions](https://github.com/akka/akka/actions) for the commit you would like to release have completed.
- [ ] Tag the release `git tag -a -s -m 'Release v$VERSION$' v$VERSION$` and push the tag `git push --tags`
- [ ] Check that the GitHub Actions release build has executed successfully (it should publish artifacts to Sonatype and documentation to Gustav)
### Check availability
- [ ] Check [reference](https://doc.akka.io/docs/akka/$VERSION$/) documentation
- [ ] Check the release on [Maven central](https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.13/$VERSION$/)
### When everything is on maven central
- [ ] `ssh akkarepo@gustav.akka.io`
- [ ] update the `current` links on `repo.akka.io` to point to the latest version with
```
ln -nsf $VERSION$ www/docs/akka/current
ln -nsf $VERSION$ www/api/akka/current
ln -nsf $VERSION$ www/japi/akka/current
```
- [ ] check changes and commit the new version to the local git repository
```
cd ~/www
git add docs/akka/current docs/akka/$VERSION$
git add api/akka/current api/akka/$VERSION$
git add japi/akka/current japi/akka/$VERSION$
git commit -m "Akka $VERSION$"
```
- [ ] push changes to the [remote git repository](https://github.com/akka/doc.akka.io)
```
cd ~/www
git push origin master
```
### Announcements
- [ ] Merge draft news item for [akka.io](https://github.com/akka/akka.github.com)
- [ ] Create a [GitHub release](https://github.com/akka/akka/releases) with the next tag version `v$VERSION$`, title and a link to the announcement
- [ ] Send a release notification to [Lightbend discuss](https://discuss.akka.io)
- [ ] Tweet using the akkateam account (or ask someone to) about the new release
- [ ] Announce on [Gitter akka/akka](https://gitter.im/akka/akka)
- [ ] Announce internally