Skip to content

Commit 355225b

Browse files
committed
Add release script
1 parent 06a8f24 commit 355225b

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set -e
2+
3+
# Fail if build number not set
4+
if [ -z "$BUILD_NUMBER" ]; then
5+
echo "Env var 'BUILD_NUMBER' must be set for this script to work correctly"
6+
exit 1
7+
fi
8+
9+
# If running inside CI login to docker
10+
if [ -z ${IS_CI} ]; then
11+
echo "Not running in CI, skipping CI setup"
12+
else
13+
if [ -z $IS_PR ] && [[ $BRANCH == "refs/heads/master" ]]; then
14+
echo "On master setting PUBLISH=true"
15+
export PUBLISH=true
16+
else
17+
echo "Skipping publish as is from PR: $PR_NUMBER or not 'refs/heads/master' BRANCH: $BRANCH"
18+
fi
19+
fi
20+
21+
22+
if [ -z ${PUBLISH} ]; then
23+
echo "Running with --skip-publish as PUBLISH not set"
24+
goreleaser --skip-publish --rm-dist
25+
else
26+
echo "Publishing release"
27+
goreleaser
28+
fi
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: build-and-release
22

33
on:
44
push:
@@ -19,5 +19,11 @@ jobs:
1919
- name: Build devcontainer for tooling
2020
run: sudo -E make devcontainer
2121

22-
- name: Run the build
23-
run: sudo -E make devcontainer-build
22+
- name: Run the release
23+
run: sudo -E make devcontainer-release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GHACTIONS_SECRET }}
26+
BUILD_NUMBER: ${{ github.run_id }}
27+
IS_CI: 1
28+
IS_PR: ${{ github.head_ref }}
29+
BRANCH: ${{ github.ref }}

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ build:
44
devcontainer:
55
docker build -f ./.devcontainer/Dockerfile ./.devcontainer -t devcontainer-cli
66

7-
8-
devcontainer-build:
7+
devcontainer-release:
98
ifdef DEVCONTAINER
109
$(error This target can only be run outside of the devcontainer as it mounts files and this fails within a devcontainer. Don't worry all it needs is docker)
1110
endif
1211
@docker run -v ${PWD}:${PWD} \
1312
--entrypoint /bin/bash \
1413
--workdir "${PWD}" \
1514
devcontainer-cli \
16-
-c "make build"
15+
-c "${PWD}/scripts/ci_release.sh"

0 commit comments

Comments
 (0)