Skip to content

Commit 1985626

Browse files
authored
Merge pull request #69 from gchq/7.2
7.2
2 parents fe610ee + 2c50faa commit 1985626

File tree

454 files changed

+38260
-6666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

454 files changed

+38260
-6666
lines changed
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Zip files on push
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build-project:
9+
runs-on: ubuntu-24.04
10+
env:
11+
# Github runners limited to 2 cores, 7Gb RAM
12+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
13+
MAX_WORKERS: 3
14+
# path of the unix file socket that the agent uses
15+
SSH_AUTH_SOCK: "/tmp/ssh-agent.sock"
16+
17+
steps:
18+
- name: Checkout
19+
id: checkout_code
20+
uses: actions/checkout@v2
21+
# See https://github.com/actions/runner/issues/712
22+
with:
23+
ref: ${{ github.ref }}
24+
25+
26+
# Set variables in github's special env file which are then automatically
27+
# read into env vars in each subsequent step
28+
- name: Set Environment Variables
29+
id: set_env_var
30+
run: |
31+
{
32+
# Map the GITHUB env vars to our own
33+
echo "BUILD_DIR=${GITHUB_WORKSPACE}"
34+
echo "BUILD_COMMIT=${GITHUB_SHA}"
35+
echo "ACTIONS_SCRIPTS_DIR=${GITHUB_WORKSPACE}/.github/workflows/scripts"
36+
37+
if [[ ${GITHUB_REF} =~ ^refs/tags/ ]]; then
38+
# strip off the 'refs/tags/' bit
39+
tag="${GITHUB_REF#refs/tags/}"
40+
echo "BUILD_TAG=${tag}"
41+
fi
42+
43+
if [[ ${GITHUB_REF} =~ ^refs/heads/ ]]; then
44+
# strip off the 'ref/heads/' bit
45+
echo "BUILD_BRANCH=${GITHUB_REF#refs/heads/}"
46+
fi
47+
48+
if [[ ${GITHUB_REF} =~ ^refs/pulls/ ]]; then
49+
echo "BUILD_IS_PULL_REQUEST=true"
50+
else
51+
echo "BUILD_IS_PULL_REQUEST=false"
52+
fi
53+
54+
if [[ ${GITHUB_REF} =~ ^refs/tags/v ]]; then
55+
echo "BUILD_IS_RELEASE=true"
56+
else
57+
echo "BUILD_IS_RELEASE=false"
58+
fi
59+
} >> $GITHUB_ENV
60+
61+
# Zipping, test_dir not packaged in with release
62+
- name: Zip
63+
run: |
64+
mkdir -p "${BUILD_DIR}/build/release_artefacts/"
65+
pushd ./war/stroom_content && zip -r "${BUILD_DIR}/build/release_artefacts/stroom-visualisations-${BUILD_TAG}.zip" . && popd
66+
67+
# Running release script
68+
- name: Release to Github
69+
id: create_release
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
run: |
73+
bash "${ACTIONS_SCRIPTS_DIR}/create_github_release.sh"
74+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
IFS=$'\n\t'
4+
5+
setup_echo_colours() {
6+
7+
# Exit the script on any error
8+
set -e
9+
10+
# shellcheck disable=SC2034
11+
if [ "${MONOCHROME}" = true ]; then
12+
RED=''
13+
GREEN=''
14+
YELLOW=''
15+
BLUE=''
16+
BLUE2=''
17+
DGREY=''
18+
NC='' # No Colour
19+
else
20+
RED='\033[1;31m'
21+
GREEN='\033[1;32m'
22+
YELLOW='\033[1;33m'
23+
BLUE='\033[1;34m'
24+
BLUE2='\033[1;34m'
25+
DGREY='\e[90m'
26+
NC='\033[0m' # No Colour
27+
fi
28+
}
29+
30+
debug_value() {
31+
32+
local name="$1"; shift
33+
local value="$1"; shift
34+
35+
if [ "${IS_DEBUG}" = true ]; then
36+
echo -e "${DGREY}DEBUG ${name}: ${value}${NC}"
37+
fi
38+
}
39+
40+
debug() {
41+
local str="$1"; shift
42+
43+
if [ "${IS_DEBUG}" = true ]; then
44+
echo -e "${DGREY}DEBUG ${str}${NC}"
45+
fi
46+
}
47+
48+
main() {
49+
IS_DEBUG=false
50+
#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
51+
52+
setup_echo_colours
53+
54+
echo -e "${GREEN}Finding asset files for release${NC}"
55+
local asset_files=()
56+
for asset_file in "${BUILD_DIR}/build/release_artefacts/"*; do
57+
echo -e "${GREEN}Found asset file: ${BLUE}${asset_file}${NC}"
58+
asset_files+=("${asset_file}")
59+
done
60+
61+
local args=()
62+
if [[ ${GITHUB_REF} =~ .*(beta|alpha).* ]]; then
63+
echo -e "${GREEN}Release is a pre-release${NC}"
64+
args+=("--prerelease")
65+
fi
66+
67+
git tag \
68+
--list "${BUILD_TAG}" \
69+
--format='%(subject)%0a%0a%(contents:body)'
70+
71+
local message
72+
message="$( \
73+
git tag \
74+
--list "${BUILD_TAG}" \
75+
--format='%(subject)%0a%0a%(contents:body)')"
76+
77+
echo "Environment Variables:"
78+
echo "BUILD_DIR: $BUILD_DIR"
79+
echo "BUILD_TAG: $BUILD_TAG"
80+
echo "ACTIONS_SCRIPTS_DIR: $ACTIONS_SCRIPTS_DIR"
81+
82+
echo -e "${GREEN}Creating release for tag ${BLUE}${BUILD_TAG}${GREEN} with message:${NC}"
83+
echo -e "${DGREY}------------------------------------------------------------------------${NC}"
84+
echo -e "${DGREY}${message}${NC}"
85+
echo -e "${DGREY}------------------------------------------------------------------------${NC}"
86+
87+
echo "DEBUG: Contents of ${BUILD_DIR}/build/release_artefacts/"
88+
ls -l "${BUILD_DIR}/build/release_artefacts/"
89+
90+
# Create the release on GitHub using the annotated tag that triggered
91+
# this build
92+
# See https://cli.github.com/manual/gh_release_create
93+
if [[ "${BUILD_TAG}" =~ v[0-9]+\.[0-9]+ ]]; then
94+
gh release create \
95+
--title "${BUILD_TAG}" \
96+
--notes "${message}" \
97+
--verify-tag \
98+
"${args[@]}" \
99+
"${BUILD_TAG}" \
100+
"${asset_files[@]}"
101+
else
102+
echo "BUILD_TAG is not set or empty. Skipping release upload."
103+
fi
104+
105+
if [ -f "${BUILD_DIR}/build/release_artefacts/test-archive.zip" ]; then
106+
echo "Deleting test-archive.zip..."
107+
rm -f "${BUILD_DIR}/build/release_artefacts/test-archive.zip"
108+
else
109+
echo "test-archive.zip does not exist, skipping."
110+
fi
111+
112+
echo "${BUILD_TAG}"
113+
114+
echo "${GREEN}Release created for tag ${BLUE}${BUILD_TAG}${NC}"
115+
}
116+
117+
main "$@"
118+
119+
# vim: set tabstop=2 shiftwidth=2 expandtab:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ TestVis/.classpath
33
/gwt-unitCache/
44
/.settings/
55
**/output/
6+
build/
67
.idea
78
*.swp
89
stroom-content-target

0 commit comments

Comments
 (0)