Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Workflow Action to build and upload webapp bundle on Release #2161

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ indent_size = 4
[*.md]
trim_trailing_whitespace = false

[*.{js,yaml}]
[*.{js,yaml,yml}]
indent_size = 2
20 changes: 19 additions & 1 deletion .github/workflows/test_docker_debian_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@ on:
# run at 17:00 every sunday
- cron: '0 17 * * 0'
push:
branches:
- 'future3/**'
paths:
- 'installation/**'
- 'ci/**'
- 'resources/**'
- 'src/jukebox/jukebox/version.py'
- 'packages*.txt'
- 'requirements*.txt'
pull_request:
# The branches below must be a subset of the branches above
branches: [ future3/develop ]
branches:
- future3/develop
- future3/main
paths:
- 'installation/**'
- 'ci/**'
- 'resources/**'
- 'src/jukebox/jukebox/version.py'
- 'packages*.txt'
- 'requirements*.txt'

# let only one instance run the test so cache is not corrupted.
# cancel already running instances as only the last run will be relevant
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/webapp_build_bundle_v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build WebApp Bundle

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest

env:
WEBAPP_ROOT_PATH: ./src/webapp

outputs:
release_upload_url: ${{ github.event.release.upload_url }}
webapp_bundle_name: ${{ steps.vars.outputs.webapp_bundle_name }}

steps:
- name: Set Output vars
id: vars
run: |
echo "webapp_bundle_name=webapp-${{ github.event.release.tag_name }}.tar.gz" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: npm install
working-directory: ${{ env.WEBAPP_ROOT_PATH }}
run: npm install
- name: npm build
working-directory: ${{ env.WEBAPP_ROOT_PATH }}
env:
CI: false
run: npm run build

- name: Create Bundle
working-directory: ${{ env.WEBAPP_ROOT_PATH }}
run: |
tar -czvf ${{ steps.vars.outputs.webapp_bundle_name }} build

- name: Artifact Upload
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.webapp_bundle_name }}
path: ${{ env.WEBAPP_ROOT_PATH }}/${{ steps.vars.outputs.webapp_bundle_name }}
retention-days: 5

upload:
needs: [build]
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Artifact Download
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.webapp_bundle_name }}

- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build.outputs.release_upload_url }}
asset_name: ${{ needs.build.outputs.webapp_bundle_name }}
asset_path: ${{ needs.build.outputs.webapp_bundle_name }}
asset_content_type: application/gzip
overwrite: true
10 changes: 7 additions & 3 deletions installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ get_version_string() {
local version_minor
local version_patch

version_major=$(grep 'VERSION_MAJOR\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_minor=$(grep 'VERSION_MINOR\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_patch=$(grep 'VERSION_PATCH\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_major=$(grep -o 'VERSION_MAJOR\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_minor=$(grep -o 'VERSION_MINOR\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_patch=$(grep -o 'VERSION_PATCH\s*=\s*[0-9]*' "${python_file}" | awk -F= '{print $2}' | tr -d ' ')
version_extra=$(grep -o 'VERSION_EXTRA\s*=\s*\".*\"' "${python_file}" | awk -F= '{print $2}' | tr -d ' "')

if [ -n "$version_major" ] && [ -n "$version_minor" ] && [ -n "$version_patch" ]; then
local version_string="${version_major}.${version_minor}.${version_patch}"
if [ -n "$version_extra" ]; then
version_string="${version_string}-${version_extra}"
fi
echo ${version_string}
else
exit_on_error "ERROR: Unable to extract version information from ${python_file}"
Expand Down
4 changes: 2 additions & 2 deletions installation/routines/setup_jukebox_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ _jukebox_core_build_libzmq_with_drafts() {
local cpu_count=${CPU_COUNT:-$(python3 -c "import os; print(os.cpu_count())")}

cd "${JUKEBOX_ZMQ_TMP_DIR}" || exit_on_error
wget --quiet https://github.com/zeromq/libzmq/releases/download/v${JUKEBOX_ZMQ_VERSION}/${zmq_tar_filename}
wget --quiet https://github.com/zeromq/libzmq/releases/download/v${JUKEBOX_ZMQ_VERSION}/${zmq_tar_filename} || exit_on_error "Download failed"
tar -xzf ${zmq_tar_filename}
rm -f ${zmq_tar_filename}
cd ${zmq_filename} || exit_on_error
Expand All @@ -68,7 +68,7 @@ _jukebox_core_download_prebuilt_libzmq_with_drafts() {
ARCH=$(get_architecture)

cd "${JUKEBOX_ZMQ_TMP_DIR}" || exit_on_error
wget --quiet https://github.com/pabera/libzmq/releases/download/v${JUKEBOX_ZMQ_VERSION}/libzmq5-${ARCH}-${JUKEBOX_ZMQ_VERSION}.tar.gz -O ${zmq_tar_filename}
wget --quiet https://github.com/pabera/libzmq/releases/download/v${JUKEBOX_ZMQ_VERSION}/libzmq5-${ARCH}-${JUKEBOX_ZMQ_VERSION}.tar.gz -O ${zmq_tar_filename} || exit_on_error "Download failed"
tar -xzf ${zmq_tar_filename}
rm -f ${zmq_tar_filename}
sudo rsync -a ./* ${JUKEBOX_ZMQ_PREFIX}/
Expand Down
2 changes: 1 addition & 1 deletion installation/routines/setup_jukebox_webapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _jukebox_webapp_download() {

cd "${INSTALLATION_PATH}/src/webapp" || exit_on_error
# URL must be set to default repo as installation can be run from different repos as well where releases may not exist
wget --quiet ${DOWNLOAD_URL} -O ${TAR_FILENAME}
wget --quiet ${DOWNLOAD_URL} -O ${TAR_FILENAME} || exit_on_error "Download failed"
tar -xzf ${TAR_FILENAME}
rm -f ${TAR_FILENAME}
cd "${INSTALLATION_PATH}" || exit_on_error
Expand Down
2 changes: 1 addition & 1 deletion src/jukebox/jukebox/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__version_info__ = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)

if VERSION_EXTRA:
__version__ = "%s.%s" % (__version__, VERSION_EXTRA)
__version__ = "%s-%s" % (__version__, VERSION_EXTRA)
__version_info__ = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_EXTRA)


Expand Down