feat(ghpublish): choose (pre)release depending on tag (#928)
While there, include integration testing to make sure the script is working as intended before using it. While there, edit maketarball.bash's comments.
This commit is contained in:
parent
7df25795c0
commit
ae0613fbb3
18
.github/workflows/ghpublish.yml
vendored
Normal file
18
.github/workflows/ghpublish.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Verifies that `./script/ghpublish.bash` is WAI
|
||||||
|
name: ghpublish
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "release/**"
|
||||||
|
- "fullbuild"
|
||||||
|
- "ghpublishbuild"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test_ghpublish_bash:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- run: ./script/ghpublish_test.bash
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@
|
||||||
/DEBIAN_INSTALLED_PACKAGE.txt
|
/DEBIAN_INSTALLED_PACKAGE.txt
|
||||||
/debops-ci
|
/debops-ci
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/ghpublish.out.txt
|
||||||
/jafar
|
/jafar
|
||||||
/*.jsonl
|
/*.jsonl
|
||||||
/miniooni
|
/miniooni
|
||||||
|
|
2
script/ghpublish-branch.out.txt
Normal file
2
script/ghpublish-branch.out.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
gh release create -p rolling --target 7327e1ff7f0cfdc5ff0335574b85dc8ceb9465b6
|
||||||
|
gh release upload rolling --clobber ABC
|
2
script/ghpublish-pr.out.txt
Normal file
2
script/ghpublish-pr.out.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
gh release create -p rolling --target 7327e1ff7f0cfdc5ff0335574b85dc8ceb9465b6
|
||||||
|
gh release upload rolling --clobber ABC
|
2
script/ghpublish-prerelease.out.txt
Normal file
2
script/ghpublish-prerelease.out.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
gh release create -p v0.0.0-alpha --target 7327e1ff7f0cfdc5ff0335574b85dc8ceb9465b6
|
||||||
|
gh release upload v0.0.0-alpha --clobber ABC
|
2
script/ghpublish-release.out.txt
Normal file
2
script/ghpublish-release.out.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
gh release create v0.0.0 --target 7327e1ff7f0cfdc5ff0335574b85dc8ceb9465b6
|
||||||
|
gh release upload v0.0.0 --clobber ABC
|
|
@ -16,10 +16,18 @@ else
|
||||||
__tag=rolling
|
__tag=rolling
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 3. determine whether this is a pre-release
|
||||||
|
prerelease="-p"
|
||||||
|
if [[ $__tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
prerelease=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh=${gh:-gh}
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# 3. create the release as a pre-release unless it already exists
|
# 4. create the release unless it already exists
|
||||||
gh release create -p $__tag --target $GITHUB_SHA || true
|
$gh release create $prerelease $__tag --target $GITHUB_SHA || true
|
||||||
|
|
||||||
# 4. publish all the assets passed as arguments to the target release
|
# 5. publish all the assets passed as arguments to the target release
|
||||||
gh release upload $__tag --clobber "$@"
|
$gh release upload $__tag --clobber "$@"
|
||||||
|
|
32
script/ghpublish_test.bash
Executable file
32
script/ghpublish_test.bash
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
# Make sure we're not going to execute gh
|
||||||
|
export gh="echo gh"
|
||||||
|
|
||||||
|
# Use a very old SHA as target
|
||||||
|
export GITHUB_SHA="7327e1ff7f0cfdc5ff0335574b85dc8ceb9465b6"
|
||||||
|
|
||||||
|
# Test 1: make sure we're publishing to rolling as a
|
||||||
|
# pre-release when the build targets a branch
|
||||||
|
export GITHUB_REF="refs/heads/feature"
|
||||||
|
./script/ghpublish.bash ABC > ghpublish.out.txt
|
||||||
|
diff ./script/ghpublish-branch.out.txt ghpublish.out.txt
|
||||||
|
|
||||||
|
# Test 2: make sure we're publishing to rolling as a
|
||||||
|
# pre-release when the build target is a PR
|
||||||
|
export GITHUB_REF="refs/pull/123/merge"
|
||||||
|
./script/ghpublish.bash ABC > ghpublish.out.txt
|
||||||
|
diff ./script/ghpublish-pr.out.txt ghpublish.out.txt
|
||||||
|
|
||||||
|
# Test 3: make sure we're publishing to a pre-release when
|
||||||
|
# we're building a tag that is not a stable release.
|
||||||
|
export GITHUB_REF="refs/tags/v0.0.0-alpha"
|
||||||
|
./script/ghpublish.bash ABC > ghpublish.out.txt
|
||||||
|
diff ./script/ghpublish-prerelease.out.txt ghpublish.out.txt
|
||||||
|
|
||||||
|
# Test 3: make sure we're publishing to a release when
|
||||||
|
# we're building a tag that is a stable release.
|
||||||
|
export GITHUB_REF="refs/tags/v0.0.0"
|
||||||
|
./script/ghpublish.bash ABC > ghpublish.out.txt
|
||||||
|
diff ./script/ghpublish-release.out.txt ghpublish.out.txt
|
|
@ -10,7 +10,7 @@ if [[ $__ref == "" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. determine whether to publish to a release or to rolling
|
# 2. determine whether to use a release tag name or just "rolling"
|
||||||
if [[ $__ref =~ ^refs/tags/v ]]; then
|
if [[ $__ref =~ ^refs/tags/v ]]; then
|
||||||
__version=${__ref#refs/tags/v}
|
__version=${__ref#refs/tags/v}
|
||||||
else
|
else
|
||||||
|
@ -25,4 +25,3 @@ set -x
|
||||||
# 4. generate the actual tarball
|
# 4. generate the actual tarball
|
||||||
go mod vendor
|
go mod vendor
|
||||||
tar -czf ooni-probe-cli-${__version}.tar.gz --transform "s,^,ooni-probe-cli-${__version}/," *
|
tar -czf ooni-probe-cli-${__version}.tar.gz --transform "s,^,ooni-probe-cli-${__version}/," *
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user