Add workflow to initiate releases

This workflow will update files in the repository for a new release. It
will:

* Update version in version.txt, CHANGELOG.md, and LICENSE
* Commit changes to main
* Create new release tag
* Generate a new development version string (patch incremented + .dev)
* Update dev version in version.txt, CHANGELOG.md, and LICENSE
* Commit changes to main
* Push changes on main to origin
* Push release tag to origin

This ensures all files are updated consistently and correctly. The
creation of the tag will then trigger the release workflow.
This commit is contained in:
Chris Roberts 2023-10-06 16:44:16 -07:00
parent c8fc8b3ad2
commit 57a0ccd8d0
5 changed files with 315 additions and 0 deletions

140
.ci/release-initiator Executable file
View File

@ -0,0 +1,140 @@
#!/usr/bin/env bash
csource="${BASH_SOURCE[0]}"
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
. "${root}/.ci/load-ci.sh"
if [ "${#}" -ne 1 ]; then
printf "Usage: %s VERSION\n" "${0}" >&2
exit 1
fi
version="${1}"
info "Updating repository files for ${version} release"
if [[ "${version}" = "v"* ]]; then
failure "Invalid version format, cannot start with 'v': %s" "${version}"
fi
if ! valid_release_version "${version}"; then
failure "Invalid version format provided: %s" "${version}"
fi
debug "Configuring git"
hashibot_git
debug "Updating version.txt with version value: %s" "${version}"
if [ ! -f "version.txt" ]; then
failure "Unable to locate version.txt file"
fi
printf "%s" "${version}" > version.txt
debug "Updating CHANGELOG.md"
if [ ! -f "CHANGELOG.md" ]; then
failure "Unable to locate CHANGLOG.md file"
fi
datestamp="$(date "+%B %d, %Y")" ||
failure "Unable to generate date"
printf "## %s (%s)\n" "${version}" "${datestamp}" > .CHANGELOG.md.new
grep -v UNRELEASED < CHANGELOG.md >> .CHANGELOG.md.new ||
failure "Unable to update CHANGELOG contents"
mv .CHANGELOG.md.new CHANGELOG.md ||
failure "Unable to overwrite CHANGELOG file"
license_date="$(date "+%Y")" ||
failure "Unable to generate year for license"
license_template="./templates/license/license.tmpl"
license_destination="./LICENSE"
debug "Updating license file: ${license_destination}"
if [ ! -f "${license_template}" ]; then
failure "Unable to locate license template (${license_template})"
fi
if [ ! -f "${license_destination}" ]; then
failure "Unable to locate license destination (${license_destination})"
fi
sed "s/%VERSION%/${version}/" "${license_template}" > "${license_destination}" ||
failure "Unable to update version in ${license_destination}"
sed -i "s/%YEAR%/${license_date}/" "${license_destination}" ||
failure "Unable to update year in ${license_destination}"
debug "Updating download version in website source"
version_file="./website/data/version.json"
if [ ! -f "${version_file}" ]; then
failure "Unable to locate version data file (%s)" "${version_file}"
fi
sed -i "s/ \"VERSION\":.*,/ \"VERSION\": \"${version}\",/" "${version_file}" ||
failure "Unable to update version data file (%s)" "${version_file}"
debug "Commit version updates"
# display changes before commit
git status
git add version.txt CHANGELOG.md LICENSE "${version_file}" ||
failure "Unable to stage updated release files for commit"
git commit -m "Release ${version}" ||
failure "Unable to commit updated files for release"
release_tag="v${version}"
debug "Creating new tag %s" "${release_tag}"
git tag "${release_tag}"
# Generate a new version for development
version_prefix="${version%.*}"
patch="${version##*.}"
new_patch=$(( "${patch}" + 1 ))
dev_version="${version_prefix}.${new_patch}.dev"
debug "Updating files for new development - %s" "${dev_version}"
debug "Updating version.txt with version value: %s" "${dev_version}"
printf "%s\n" "${dev_version}" > version.txt
debug "Updating CHANGELOG"
printf "## %s (UNRELEASED)\n\nFEATURES:\n\nIMPROVEMENTS:\n\nBUG FIXES:\n\nVAGRANT-GO:\n\n" "${dev_version}" > .CHANGELOG.md.new
cat CHANGELOG.md >> .CHANGELOG.md.new
mv .CHANGELOG.md.new CHANGELOG.md ||
failure "Unable to overwrite CHANGELOG file"
debug "Updating LICENSE"
sed "s/%VERSION%/${dev_version}/" "${license_template}" > LICENSE ||
failure "Unable to update LICENSE"
debug "Commit development version updates"
# display changes before commit
git status
git add version.txt CHANGELOG.md LICENSE ||
failure "Unable to stage updated development files for commit"
git commit -m "Release ${version}" ||
failure "Unable to commit updated files for development"
# Now that all changes are complete, push
debug "Pushing all changes to origin"
git push origin main ||
failure "Unable to push changes to main"
git push origin "${release_tag}" ||
failure "Unable to push tag to main"

24
.github/workflows/initiate-release.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Start Vagrant Release Process
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release Version (example: 1.0.0)'
required: true
type: string
jobs:
start-release:
if: github.repository == 'hashicorp/vagrant'
name: Initiate Release
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Run initiator
run: ./.ci/release-initiator "${VERSION}"
env:
VERSION: ${{ inputs.release_version }}
# NOTE: custom token is used so pushed tag will trigger release workflow
HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }}
HASHIBOT_USERNAME: vagrant-bot

View File

@ -0,0 +1,90 @@
<html>
<body>
<p>
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
“Business Source License” is a trademark of MariaDB Corporation Ab.
</p>
<p>
Parameters
</p>
<ul>
<li>
Licensor: HashiCorp, Inc.
</li>
<li>
Licensed Work: Vagrant %VERSION%. The Licensed Work is (c) %YEAR% HashiCorp, Inc.
</li>
<li>
Additional Use Grant: You may make production use of the Licensed Work,
provided such use does not include offering the Licensed Work
to third parties on a hosted or embedded basis which is
competitive with HashiCorp's products.
</li>
<li>
Change Date: Four years from the date the Licensed Work is published.
</li>
<li>
Change License: MPL 2.0
</li>
</ul>
<p>
For information about alternative licensing arrangements for the Licensed Work, please contact licensing@hashicorp.com.
</p>
<p>
Notice
</p>
<p>
Business Source License 1.1
</p>
<p>
Terms
</p>
<p>
The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited production use.
</p>
<p>
Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.
</p>
<p>
If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.
</p>
<p>
All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.
</p>
<p>
You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.
</p>
<p>
Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.
</p>
<p>
This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).
</p>
<p>
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.
</p>
</body>
</html>

Binary file not shown.

View File

@ -0,0 +1,61 @@
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
“Business Source License” is a trademark of MariaDB Corporation Ab.
Parameters
Licensor: HashiCorp, Inc.
Licensed Work: Vagrant %VERSION%. The Licensed Work is (c) %YEAR% HashiCorp, Inc.
Additional Use Grant: You may make production use of the Licensed Work,
provided such use does not include offering the Licensed Work
to third parties on a hosted or embedded basis which is
competitive with HashiCorp's products.
Change Date: Four years from the date the Licensed Work is published.
Change License: MPL 2.0
For information about alternative licensing arrangements for the Licensed Work,
please contact licensing@hashicorp.com.
Notice
Business Source License 1.1
Terms
The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited production use.
Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.
If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.
All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.
You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.
Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.
This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.