Created
August 7, 2012 19:16
-
-
Save luontola/3288542 to your computer and use it in GitHub Desktop.
Build scripts from https://github.com/orfjackal/jumi/tree/8401c1ae319996d7d9af7f5132c9c15d91f7a38d/scripts
This file contains hidden or 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
| #!/bin/sh | |
| set -eu | |
| : ${GO_PIPELINE_COUNTER:?} | |
| : ${GPG_KEYNAME:?} | |
| : ${PWD:?} | |
| set -x | |
| RELEASE_VERSION=`ruby scripts/get-release-version.rb $GO_PIPELINE_COUNTER` | |
| RELEASE_NOTES=`ruby scripts/get-release-notes.rb RELEASE-NOTES.md` | |
| TAG="v$RELEASE_VERSION" | |
| ruby scripts/prepare-release-notes.rb RELEASE-NOTES.md "$RELEASE_VERSION" | |
| git add RELEASE-NOTES.md | |
| git commit -m "Release $RELEASE_VERSION" | |
| git tag -u "$GPG_KEYNAME" -m "Jumi $RELEASE_VERSION" -m "$RELEASE_NOTES" "$TAG" | |
| export RELEASE_REVISION=`git rev-parse HEAD` | |
| mkdir build | |
| echo "$RELEASE_VERSION" > build/version | |
| echo "$RELEASE_REVISION" > build/revision | |
| echo "$RELEASE_NOTES" > build/release-notes | |
| mvn versions:set \ | |
| --batch-mode \ | |
| --errors \ | |
| -DgenerateBackupPoms=false \ | |
| -DnewVersion="$RELEASE_VERSION" \ | |
| --file parent/pom.xml | |
| mvn clean deploy \ | |
| --batch-mode \ | |
| --errors \ | |
| -Psonatype-oss-release \ | |
| -Dgpg.keyname="$GPG_KEYNAME" \ | |
| -Dgpg.passphrase="" \ | |
| -DaltDeploymentRepository="staging::default::file://$PWD/staging" | |
| ruby scripts/bump-release-notes.rb RELEASE-NOTES.md | |
| git add RELEASE-NOTES.md | |
| git commit -m "Prepare for next development iteration" | |
| git init --bare staging.git | |
| git push staging.git "$TAG" | |
| git push staging.git HEAD:master |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Build Summary</title> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| $(function () { | |
| $('.include').each(function (index, element) { | |
| $(element).text('Loading...'); | |
| var path = $(element).attr('path'); | |
| $.get(path, function (content) { | |
| $(element).text(content); | |
| }) | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <p>Version: <code class="include" path="../build/version"></code></p> | |
| <p>Revision: <code class="include" path="../build/revision"></code></p> | |
| <p>Release Notes:</p> | |
| <pre class="include" path="../build/release-notes"></pre> | |
| </body> | |
| </html> |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| require 'date' | |
| unless ARGV.length == 1 | |
| puts "Usage: #{$0} RELEASE_NOTES_FILE" | |
| exit 1 | |
| end | |
| RELEASE_NOTES_FILE = ARGV.shift | |
| old_release_notes = IO.read(RELEASE_NOTES_FILE) | |
| new_release_notes = old_release_notes.sub(/^(### Jumi)/, | |
| "### next release\n\n- TBD\n\n\\1") | |
| File.open(RELEASE_NOTES_FILE, 'wb') { |file| | |
| file.write(new_release_notes) | |
| } |
This file contains hidden or 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
| #!/bin/sh | |
| set -eu | |
| set -x | |
| RELEASE_NOTES=`cat build/release-notes` | |
| # Require the release notes to contain something else than just the TBD placeholder | |
| if echo "$RELEASE_NOTES" | grep --line-regexp --quiet "\- TBD" | |
| then | |
| echo "Release notes not filled in" | |
| exit 1 | |
| fi |
This file contains hidden or 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
| #!/bin/sh | |
| set -eu | |
| set -x | |
| mvn clean verify \ | |
| --batch-mode \ | |
| --errors \ | |
| -Pcoverage-report \ | |
| -DskipTests \ | |
| -Dinvoker.skip | |
| ruby scripts/generate-coverage-report-index.rb coverage-reports/index.html |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| require 'fileutils' | |
| def module_list_item(module_index) | |
| module_name = module_index.split('/').first | |
| " <li><a href=\"#{module_index}\">#{module_name}</a></li>" | |
| end | |
| def write(file, content) | |
| FileUtils.mkdir_p(File.dirname(file)) | |
| File.open(file, 'wb') { |f| f.write(content) } | |
| end | |
| unless ARGV.length == 1 | |
| puts "Usage: #{$0} OUTPUT_FILE" | |
| exit 1 | |
| end | |
| OUTPUT_FILE = ARGV.shift | |
| module_list_items = Dir.glob('*/target/pit-reports/*/index.html').sort. | |
| map { |module_index| module_list_item(module_index) }. | |
| join("\n") | |
| write OUTPUT_FILE, <<eos | |
| <html> | |
| <head> | |
| <title>Pit Test Coverage Report</title> | |
| </head> | |
| <body> | |
| <h1>Pit Test Coverage Report</h1> | |
| <h3>Modules</h3> | |
| <ul> | |
| #{module_list_items} | |
| </ul> | |
| </body> | |
| </html> | |
| eos |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| unless ARGV.length == 1 | |
| puts "Usage: #{$0} RELEASE_NOTES_FILE" | |
| exit 1 | |
| end | |
| RELEASE_NOTES_FILE = ARGV.shift | |
| all_releases = IO.read(RELEASE_NOTES_FILE) | |
| next_release = /^### next release$(.+?)^### Jumi/m.match(all_releases) | |
| unless next_release | |
| raise "release notes for next release not found in: #{all_releases}" | |
| end | |
| puts next_release[1].strip |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| require 'rexml/document' | |
| def get_release_version(snapshot_version, build_number) | |
| snapshot_suffix = /-SNAPSHOT$/ | |
| unless snapshot_version =~ snapshot_suffix | |
| raise "Not a snapshot version: #{snapshot_version}" | |
| end | |
| snapshot_version.gsub(snapshot_suffix, ".#{build_number}") | |
| end | |
| unless ARGV.length == 1 | |
| puts "Usage: #{$0} BUILD_NUMBER" | |
| exit 1 | |
| end | |
| BUILD_NUMBER = Integer(ARGV.shift) | |
| pom = REXML::Document.new(File.new("parent/pom.xml")) | |
| old_version = pom.elements["/project/version"].text | |
| new_version = get_release_version(old_version, BUILD_NUMBER) | |
| puts new_version |
This file contains hidden or 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
| <pipeline name="jumi" isLocked="false"> | |
| <environmentvariables> | |
| <variable name="GPG_KEYNAME"> | |
| <value>build-server@jumi.fi</value> | |
| </variable> | |
| <variable name="JAVA_HOME"> | |
| <value>/opt/jdk1.7.0</value> | |
| </variable> | |
| </environmentvariables> | |
| <materials> | |
| <git url="git://github.com/orfjackal/jumi.git" materialName="sources" /> | |
| </materials> | |
| <stage name="build" cleanWorkingDir="true"> | |
| <jobs> | |
| <job name="build-release"> | |
| <tasks> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>./scripts/build-release.sh 2>&1</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| </tasks> | |
| <tabs> | |
| <tab name="Changelog" path="scripts/build-summary.html" /> | |
| </tabs> | |
| <resources> | |
| <resource>maven</resource> | |
| <resource>ruby</resource> | |
| </resources> | |
| <artifacts> | |
| <artifact src="build" /> | |
| <artifact src="staging" /> | |
| <artifact src="staging.git" /> | |
| <artifact src="scripts" /> | |
| <test src="*/target/surefire-reports" dest="test-reports" /> | |
| <test src="*/target/failsafe-reports" dest="test-reports" /> | |
| <test src="*/target/invoker-reports" dest="test-reports" /> | |
| <test src="*/target/it/*/build.log" dest="test-reports" /> | |
| </artifacts> | |
| </job> | |
| </jobs> | |
| </stage> | |
| <stage name="analyze"> | |
| <jobs> | |
| <job name="coverage-report"> | |
| <tasks> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>./scripts/coverage-report.sh 2>&1</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| </tasks> | |
| <tabs> | |
| <tab name="Coverage" path="coverage-reports/index.html" /> | |
| </tabs> | |
| <resources> | |
| <resource>maven</resource> | |
| <resource>ruby</resource> | |
| </resources> | |
| <artifacts> | |
| <artifact src="*/target/pit-reports" dest="coverage-reports" /> | |
| <artifact src="coverage-reports" /> | |
| </artifacts> | |
| </job> | |
| </jobs> | |
| </stage> | |
| </pipeline> | |
| <pipeline name="jumi-publish" labeltemplate="${jumi}" isLocked="true"> | |
| <environmentvariables> | |
| <variable name="GIT_REPOSITORY"> | |
| <value>git@github.com:orfjackal/jumi.git</value> | |
| </variable> | |
| <variable name="DEPLOY_USERNAME"> | |
| <value>orfjackal</value> | |
| </variable> | |
| <variable name="DEPLOY_PASSWORD" secure="true"> | |
| <encryptedValue>gXPoeL2pbgx3VHNk=</encryptedValue> | |
| </variable> | |
| </environmentvariables> | |
| <materials> | |
| <pipeline pipelineName="jumi" stageName="build" materialName="jumi" /> | |
| </materials> | |
| <stage name="pre-check" cleanWorkingDir="true"> | |
| <approval type="manual" /> | |
| <jobs> | |
| <job name="check-release-notes"> | |
| <tasks> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="build"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="scripts"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>chmod a+x scripts/*.sh</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>./scripts/check-release-notes.sh 2>&1</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| </tasks> | |
| </job> | |
| </jobs> | |
| </stage> | |
| <stage name="ossrh" cleanWorkingDir="true"> | |
| <jobs> | |
| <job name="promote-staging"> | |
| <tasks> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="build"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="staging"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="scripts"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>chmod a+x scripts/*.sh</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>./scripts/promote-staging.sh 2>&1</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| </tasks> | |
| <resources> | |
| <resource>maven</resource> | |
| <resource>ruby</resource> | |
| </resources> | |
| </job> | |
| </jobs> | |
| </stage> | |
| <stage name="github" cleanWorkingDir="true"> | |
| <jobs> | |
| <job name="push-staging"> | |
| <tasks> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="build"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="staging.git"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <fetchartifact pipeline="jumi" stage="build" job="build-release" srcdir="scripts"> | |
| <runif status="passed" /> | |
| </fetchartifact> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>chmod a+x scripts/*.sh</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| <exec command="sh"> | |
| <arg>-c</arg> | |
| <arg>./scripts/push-staging.sh 2>&1</arg> | |
| <runif status="passed" /> | |
| </exec> | |
| </tasks> | |
| </job> | |
| </jobs> | |
| </stage> | |
| </pipeline> |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| require 'date' | |
| unless ARGV.length == 2 | |
| puts "Usage: #{$0} RELEASE_NOTES_FILE RELEASE_VERSION" | |
| exit 1 | |
| end | |
| RELEASE_NOTES_FILE = ARGV.shift | |
| RELEASE_VERSION = ARGV.shift | |
| old_release_notes = IO.read(RELEASE_NOTES_FILE) | |
| new_release_notes = old_release_notes.sub(/^### next release$/, | |
| "### Jumi #{RELEASE_VERSION} (#{Date.today.strftime('%F')})") | |
| File.open(RELEASE_NOTES_FILE, 'wb') { |file| | |
| file.write(new_release_notes) | |
| } |
This file contains hidden or 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
| #!/bin/sh | |
| set -eu | |
| : ${DEPLOY_USERNAME:?} | |
| : ${DEPLOY_PASSWORD:?} | |
| set -x | |
| VERSION=`cat build/version` | |
| ruby scripts/upload-maven-repository.rb staging https://oss.sonatype.org/service/local/staging/deploy/maven2 | |
| # Cannot set plugin version in parent POM, because it's not checked out to working directory when publishing | |
| mvn org.sonatype.plugins:nexus-maven-plugin:2.1:staging-close \ | |
| --batch-mode \ | |
| --errors \ | |
| -Dnexus.url=https://oss.sonatype.org/ \ | |
| -Dnexus.username="$DEPLOY_USERNAME" \ | |
| -Dnexus.password="$DEPLOY_PASSWORD" \ | |
| -Dnexus.groupId=fi.jumi \ | |
| -Dnexus.artifactId=parent \ | |
| -Dnexus.version="$VERSION" \ | |
| -Dnexus.description="Jumi $VERSION" |
This file contains hidden or 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
| #!/bin/sh | |
| set -eu | |
| : ${GIT_REPOSITORY:?} | |
| set -x | |
| git clone "$GIT_REPOSITORY" work | |
| cd work | |
| git remote add staging ../staging.git | |
| git fetch staging | |
| git merge staging/master | |
| git push origin master | |
| git push origin --tags |
This file contains hidden or 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
| # Copyright © 2011-2012, Esko Luontola <www.orfjackal.net> | |
| # This software is released under the Apache License 2.0. | |
| # The license text is at http://www.apache.org/licenses/LICENSE-2.0 | |
| def get_env_var(name) | |
| ENV[name] or raise "Missing environment variable: #{name}" | |
| end | |
| def http_put(file, target_url, username, password) | |
| puts "PUT #{target_url}" | |
| system('curl', | |
| '--fail', '--silent', '--show-error', | |
| '--basic', '--user', username+':'+password, | |
| '--upload-file', file, | |
| target_url | |
| ) or raise "Failed to upload #{target_url}" | |
| end | |
| unless ARGV.length == 2 | |
| puts "Usage: #{$0} SOURCE_DIR DEPLOY_URL" | |
| exit 1 | |
| end | |
| SOURCE_DIR = ARGV.shift | |
| DEPLOY_URL = ARGV.shift | |
| deploy_username = get_env_var('DEPLOY_USERNAME') | |
| deploy_password = get_env_var('DEPLOY_PASSWORD') | |
| puts "Copying from #{SOURCE_DIR} to #{DEPLOY_URL}" | |
| Dir.chdir(SOURCE_DIR) do | |
| Dir.glob('**/*').select { |path| File.file?(path) }.each do |path| | |
| http_put(path, "#{DEPLOY_URL}/#{path}", deploy_username, deploy_password) | |
| end | |
| end | |
| puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment