Commit 53618fee authored by Robert Knight's avatar Robert Knight

Fetch tags from git remote before determining new version

The package version is now determined based on the highest
previously-tagged version. This means we need to fetch existing tags
before we can determine the new version number.
parent 753272e2
...@@ -39,6 +39,13 @@ node { ...@@ -39,6 +39,13 @@ node {
returnStdout: true returnStdout: true
).trim() ).trim()
// Update local information about tags to match the remote,
// including removing any local tags that no longer exist.
//
// The `--prune-tags` option is not supported in Git 2.11 so we
// use the workaround from https://github.com/git/git/commit/97716d217c1ea00adfc64e4f6bb85c1236d661ff
sh "git fetch --quiet --prune origin 'refs/tags/*:refs/tags/*' "
// Determine version number for next release. // Determine version number for next release.
pkgVersion = sh ( pkgVersion = sh (
script: 'git tag --list | sort --version-sort --reverse | head -n1 | tail -c +2', script: 'git tag --list | sort --version-sort --reverse | head -n1 | tail -c +2',
...@@ -122,10 +129,8 @@ node { ...@@ -122,10 +129,8 @@ node {
[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 's3-cdn'] [$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 's3-cdn']
]) { ]) {
// Configure commit author for version bump commit and auth credentials // Configure author for tag and auth credentials for pushing tag to GitHub.
// for pushing tag to GitHub. // See https://git-scm.com/docs/git-credential-store.
//
// See https://git-scm.com/docs/git-credential-store
sh """ sh """
git config --replace-all user.email ${env.GITHUB_USERNAME}@hypothes.is git config --replace-all user.email ${env.GITHUB_USERNAME}@hypothes.is
git config --replace-all user.name ${env.GITHUB_USERNAME} git config --replace-all user.name ${env.GITHUB_USERNAME}
...@@ -133,13 +138,6 @@ node { ...@@ -133,13 +138,6 @@ node {
echo https://${env.GITHUB_USERNAME}:${env.GITHUB_TOKEN}@github.com >> \$HOME/.git-credentials echo https://${env.GITHUB_USERNAME}:${env.GITHUB_TOKEN}@github.com >> \$HOME/.git-credentials
""" """
// Update local information about tags to match the remote,
// including removing any local tags that no longer exist.
//
// The `--prune-tags` option is not supported in Git 2.11 so we
// use the workaround from https://github.com/git/git/commit/97716d217c1ea00adfc64e4f6bb85c1236d661ff
sh "git fetch --quiet --prune origin 'refs/tags/*:refs/tags/*' "
// Create and push a git tag. // Create and push a git tag.
sh "git tag v${newPkgVersion}" sh "git tag v${newPkgVersion}"
sh "git push https://github.com/hypothesis/client.git v${newPkgVersion}" sh "git push https://github.com/hypothesis/client.git v${newPkgVersion}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment