Merge pull request #13152 from chrisroberts/build-release-workflows

Update release workflow
This commit is contained in:
Chris Roberts 2023-05-15 11:02:35 -07:00 committed by GitHub
commit 71bc6b3dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 126 deletions

17
.ci/release Executable file
View File

@ -0,0 +1,17 @@
#!/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 [ -z "${tag}" ]; then
failure "Tag variable is unset (will be automatically set on tag push)"
fi
if [ -z "${full_sha}" ]; then
failure "The full_sha variable is unexpectedly missing, cannot trigger release"
fi
info "Triggering release %s (%s)" "${tag}" "${full_sha}"
github_repository_dispatch "vagrant-builders" "hashicorp-release" "commit_id=${full_sha}" "tag=${tag}"

View File

@ -1,106 +0,0 @@
#!/usr/bin/env bash
# NOTE: This release will generate a new release on the installers
# repository which in turn triggers a full package build
target_owner="hashicorp"
target_repository="vagrant-builders"
csource="${BASH_SOURCE[0]}"
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
. "${root}/.ci/init.sh"
pushd "${root}"
# Install ghr
install_ghr
# Build our gem
wrap gem build ./*.gemspec \
"Failed to build Vagrant RubyGem"
# Get the path of our new gem
g=(vagrant*.gem)
gem=$(printf "%s" "${g[0]}")
# Determine the version of the release
vagrant_version="$(gem specification "${gem}" version)"
vagrant_version="${vagrant_version##*version: }"
# Install submodules
wrap git submodule update --init --recursive \
"Failed to install git submodules"
# Build our binaries
# Build linux amd64 binary
wrap make bin/linux \
"Failed to build the Vagrant go linux amd64 binary"
# Rename our binary
wrap mv vagrant vagrant-go_linux_amd64 \
"Failed to rename vagrant linux amd64 binary"
# Zip the binary
wrap zip "vagrant-go_${vagrant_version}_linux_amd64.zip" vagrant-go_linux_amd64 \
"Failed to compress go linux amd64 binary"
# Build linux 386 binary
wrap make bin/linux-386 \
"Failed to build the Vagrant go linux 386 binary"
# Rename our binary
wrap mv vagrant vagrant-go_linux_386 \
"Failed to rename vagrant linux 386 binary"
# Zip the binary
wrap zip "vagrant-go_${vagrant_version}_linux_386.zip" vagrant-go_linux_386 \
"Failed to compress go linux 386 binary"
# Build darwin binary
wrap make bin/darwin \
"Failed to build the Vagrant go darwin amd64 binary"
# Rename our binary
wrap mv vagrant vagrant-go_darwin_amd64 \
"Failed to rename vagrant darwin amd64 binary"
# Zip the binary
wrap zip "vagrant-go_${vagrant_version}_darwin_amd64.zip" vagrant-go_darwin_amd64 \
"Failed to compress go darwin amd64 binary"
wrap mkdir release-assets \
"Failed to create release assets directory"
wrap mv vagrant*.gem release-assets \
"Failed to move Vagrant RubyGem asset to release asset directory"
wrap mv vagrant-go*.zip release-assets \
"Failed to move Vagrant go assets to release asset directory"
# We want to release into the builders repository so
# update the repository variable with the desired destination
repo_owner="${target_owner}"
repo_name="${target_repository}"
full_sha="main"
# Use the hashibot token since we are creating the (pre)release
# in a different repository.
export GITHUB_TOKEN="${HASHIBOT_TOKEN}"
if [ -z "${tag}" ]; then
echo "Generating Vagrant RubyGem pre-release... "
version="v${vagrant_version}+${short_sha}"
prerelease "${version}" ./release-assets
else
# Validate this is a proper release version
if ! valid_release_version "${vagrant_version}"; then
fail "Invalid version format for Vagrant release: ${vagrant_version}"
fi
echo "Generating Vagrant RubyGem release... "
version="v${vagrant_version}"
release "${version}" ./release-assets
fi
slack -m "New Vagrant installers release triggered: *${version}*"

View File

@ -1,11 +1,6 @@
on:
push:
branches:
- 'build-*'
tags: '*'
paths-ignore:
- 'CHANGELOG.md'
- 'website/**'
tags: 'v*'
jobs:
trigger-release:
@ -15,19 +10,7 @@ jobs:
steps:
- name: Code Checkout
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Create Builders Release
run: ./.ci/release.sh
working-directory: ${{github.workspace}}
- name: Trigger Build
run: ./.ci/release
env:
HASHIBOT_EMAIL: ${{ secrets.HASHIBOT_EMAIL }}
HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }}
HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}