File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -o errexit -o nounset -o pipefail
4+
5+ JSONNET_VERSION=" $( grep -Ee ' ^\s*const\s+version\s*=\s*"[^"]+"\s*$' vm.go | sed -E -e ' s/[^"]+"([^"]+)".*/\1/' ) "
6+
7+ # GITHUB_REF is set by GH actions, see
8+ # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
9+
10+ VERSION_SUFFIX=
11+ if [[ ( " ${GITHUB_REF_TYPE} " ! = ' branch' || " ${GITHUB_REF_NAME} " ! = " prepare-release" ) &&
12+ ( " ${GITHUB_REF_TYPE} " ! = ' tag' || " ${GITHUB_REF_NAME} " ! = " ${JSONNET_VERSION} " ) ]]; then
13+ >&2 echo ' WARNING: Jsonnet library version in header does not match release ref. Adding commit suffix.'
14+ VERSION_SUFFIX=" -${GITHUB_SHA: 0: 9} "
15+ fi
16+
17+ # A prefix is added to better match the GitHub generated archives.
18+ PREFIX=" go-jsonnet-${JSONNET_VERSION}${VERSION_SUFFIX} "
19+ ARCHIVE=" go-jsonnet-${JSONNET_VERSION}${VERSION_SUFFIX} .tar.gz"
20+ git archive --format=tar --prefix=" ${PREFIX} " / " ${GITHUB_SHA} " | gzip > " $ARCHIVE "
21+ ARCHIVE_SHA=$( shasum -a 256 " $ARCHIVE " | awk ' {print $1}' )
22+
23+ echo " archive_sha256=${ARCHIVE_SHA} " >> " $GITHUB_OUTPUT "
24+ echo " go_jsonnet_version=${JSONNET_VERSION} " >> " $GITHUB_OUTPUT "
25+ echo " go_jsonnet_version_permanent=${JSONNET_VERSION}${VERSION_SUFFIX} " >> " $GITHUB_OUTPUT "
Original file line number Diff line number Diff line change 3838 with :
3939 version : latest
4040 args : release --clean --draft
41+
42+ create_source_archive :
43+ permissions :
44+ contents : write
45+ runs-on : ubuntu-22.04
46+ steps :
47+ - name : Checkout
48+ uses : actions/checkout@v4
49+ - name : Create release archive
50+ id : create_archive
51+ run : .github/workflows/create_archive.sh
52+ - name : Release
53+ uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
54+ with :
55+ name : ${{ steps.create_archive.outputs.go_jsonnet_version }}
56+ tag_name : ${{ steps.create_archive.outputs.go_jsonnet_version }}
57+ prerelease : ${{ inputs.prerelease }}
58+ draft : true
59+ fail_on_unmatched_files : true
60+ files : go-jsonnet-*.tar.gz
You can’t perform that action at this time.
0 commit comments