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

use same build prepare file, sync versions across several files #348

Open
wants to merge 6 commits into
base: v2.x/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/explorer-jes-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- name: '[Build] Nodejs project build'
run: npm run prod

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand All @@ -52,6 +64,18 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- name: '[Build] Nodejs project build'
run: npm run prod

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand Down Expand Up @@ -81,6 +105,15 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand All @@ -103,6 +136,18 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- name: '[Build] Nodejs project build'
run: npm run prod

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand All @@ -128,6 +173,18 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- name: '[Build] Nodejs project build'
run: npm run prod

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand Down Expand Up @@ -160,6 +217,15 @@ jobs:

- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: actions/setup-node@v2
with:
node-version: 10.18.1

- name: '[Setup] NodeJS project setup'
uses: zowe-actions/nodejs-actions/setup@main
with:
package-name: 'org.zowe.explorer-jes'

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
Expand Down
21 changes: 15 additions & 6 deletions .pax/prepare-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,36 @@ fi
# copy explorer-jes to target folder
echo "[${SCRIPT_NAME}] copying explorer JES backend ..."
mkdir -p "${PAX_WORKSPACE_DIR}/content/web"
cp README.md "${PAX_WORKSPACE_DIR}/content/web"
cp README.md "${PAX_WORKSPACE_DIR}/content"
cp LICENSE "${PAX_WORKSPACE_DIR}/content"
cp CHANGELOG.md "${PAX_WORKSPACE_DIR}/content"
# do we need these?
cp package.json "${PAX_WORKSPACE_DIR}/content/web"
cp package-lock.json "${PAX_WORKSPACE_DIR}/content/web"
cp -r dist/. "${PAX_WORKSPACE_DIR}/content/web"
mv "${PAX_WORKSPACE_DIR}/content/web/zlux-hooks/config" "${PAX_WORKSPACE_DIR}/content/config"
cp manifest.yaml "${PAX_WORKSPACE_DIR}/content"
cp pluginDefinition.prod.json "${PAX_WORKSPACE_DIR}/content/pluginDefinition.json"

# update build information
# BRANCH_NAME and BUILD_NUMBER is Jenkins environment variable
echo "[${SCRIPT_NAME}] copy and update manifest.yaml"
commit_hash=$(git rev-parse --verify HEAD)
current_timestamp=$(date +%s%3N)
current_version=$(node -e "process.stdout.write(require('./package.json').version)")
sed -e "s|{{build\.branch}}|${BRANCH_NAME}|g" \
-e "s|{{build\.number}}|${BUILD_NUMBER}|g" \
-e "s|{{build\.commitHash}}|${commit_hash}|g" \
-e "s|{{build\.timestamp}}|${current_timestamp}|g" \
"${PAX_WORKSPACE_DIR}/content/manifest.yaml" > "${PAX_WORKSPACE_DIR}/content/manifest.yaml.tmp"
mv "${PAX_WORKSPACE_DIR}/content/manifest.yaml.tmp" "${PAX_WORKSPACE_DIR}/content/manifest.yaml"
echo "[${SCRIPT_NAME}] manifest:"
-e "s|^version:.*$|version: ${current_version}|g" \
"manifest.yaml" > "${PAX_WORKSPACE_DIR}/content/manifest.yaml"
echo "[${SCRIPT_NAME}] manifest.yaml:"
cat "${PAX_WORKSPACE_DIR}/content/manifest.yaml"

echo "[${SCRIPT_NAME}] copy and update pluginDefinition.json"
sed -e "s|{{version}}|${current_version}|g" \
"pluginDefinition.prod.json" > "${PAX_WORKSPACE_DIR}/content/pluginDefinition.json"
echo "[${SCRIPT_NAME}] pluginDefinition.json:"
cat "${PAX_WORKSPACE_DIR}/content/pluginDefinition.json"

# move content to another folder
rm -fr "${PAX_WORKSPACE_DIR}/ascii"
mkdir -p "${PAX_WORKSPACE_DIR}/ascii"
Expand Down
31 changes: 2 additions & 29 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# base image tag
ARG ZOWE_BASE_IMAGE=latest-ubuntu

FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE} AS builder
FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE}

##################################
# labels
Expand All @@ -24,39 +24,12 @@ LABEL name="JES Explorer" \
summary="IBM z/OS Jobs UI service" \
description="This Zowe UI component can display jobs running on z/OS"

##################################
# switch context
USER zowe
WORKDIR /home/zowe

##################################
# copy files
COPY --chown=zowe:zowe component .

##################################
# build component
# pretty same as .pax/prepare-workspace.sh. any way we can merge?
RUN npm ci --no-audit --ignore-scripts \
&& npm run prod \
&& mkdir -p final/web \
&& cp README.md final \
&& cp package.json final/web \
&& cp package-lock.json final/web \
&& cp -r dist/. final/web \
&& mv final/web/zlux-hooks/config final/config \
&& cp manifest.yaml final \
&& cp pluginDefinition.prod.json final/pluginDefinition.json

##################################
# second stage
FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE}

##################################
# switch context
USER zowe
WORKDIR /component

##################################
# copy files
COPY --from=builder --chown=zowe:zowe /home/zowe/final ./
COPY --chown=zowe:zowe component .
COPY --chown=zowe:zowe component/LICENSE /licenses
42 changes: 9 additions & 33 deletions container/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ package_release=$(echo "${package_version}" | awk -F. '{print $1;}')
# copy Dockerfile
echo ">>>>> copy Dockerfile to ${linux_distro}/${cpu_arch}/Dockerfile"
cd "${BASE_DIR}"
rm -fr "${linux_distro}/${cpu_arch}"
mkdir -p "${linux_distro}/${cpu_arch}"
if [ ! -f Dockerfile ]; then
echo "Error: Dockerfile file is missing."
Expand All @@ -75,46 +76,21 @@ rm -fr "${BASE_DIR}/${WORK_DIR}"
mkdir -p "${BASE_DIR}/${WORK_DIR}"

###############################
echo ">>>>> prepare basic files"
echo ">>>>> prepare build"
cd "${REPO_ROOT_DIR}"
cp README.md "${BASE_DIR}/${WORK_DIR}"
cp LICENSE "${BASE_DIR}/${WORK_DIR}"
cp CHANGELOG.md "${BASE_DIR}/${WORK_DIR}"
cp package.json "${BASE_DIR}/${WORK_DIR}"
cp package-lock.json "${BASE_DIR}/${WORK_DIR}"
cp pluginDefinition.json "${BASE_DIR}/${WORK_DIR}"
cp pluginDefinition.prod.json "${BASE_DIR}/${WORK_DIR}"
cp webpack.config.js "${BASE_DIR}/${WORK_DIR}"
cp jsconfig.json "${BASE_DIR}/${WORK_DIR}"
cp .npmrc "${BASE_DIR}/${WORK_DIR}"
cp .npmignore "${BASE_DIR}/${WORK_DIR}"
cp -r plugin-definition "${BASE_DIR}/${WORK_DIR}"
cp -r WebContent "${BASE_DIR}/${WORK_DIR}"

###############################
echo ">>>>> prepare manifest.json"
cd "${REPO_ROOT_DIR}"
if [ -n "${GITHUB_PR_ID}" ]; then
GITHUB_BRANCH=PR-${GITHUB_PR_ID}
else
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
fi
echo " - branch: ${GITHUB_BRANCH}"
echo " - build number: ${GITHUB_RUN_NUMBER}"
echo " - commit hash: ${GITHUB_SHA}"
# assume to run in Github Actions
cat manifest.yaml | \
sed -e "s#{{build\.branch}}#${GITHUB_BRANCH}#" \
-e "s#{{build\.number}}#${GITHUB_RUN_NUMBER}#" \
-e "s#{{build\.commitHash}}#${GITHUB_SHA}#" \
-e "s#{{build\.timestamp}}#$(date +%s)#" \
> "${BASE_DIR}/${WORK_DIR}/manifest.yaml"
./.pax/prepare-workspace.sh
cp -r .pax/ascii/. "${BASE_DIR}/${WORK_DIR}"
cp -r .pax/content/. "${BASE_DIR}/${WORK_DIR}"

###############################
# copy to target context
echo ">>>>> copy to target build context"
cp -r "${BASE_DIR}/${WORK_DIR}" "${BASE_DIR}/${linux_distro}/${cpu_arch}/component"

###############################
echo ">>>>> list files"
find "${BASE_DIR}/${WORK_DIR}"

###############################
# done
echo ">>>>> all done"
35 changes: 35 additions & 0 deletions container/ubuntu/amd64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#######################################################################
# This program and the accompanying materials are made available
# under the terms of the Eclipse Public License v2.0 which
# accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
#######################################################################

# base image tag
ARG ZOWE_BASE_IMAGE=latest-ubuntu

FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE}

##################################
# labels
LABEL name="JES Explorer" \
maintainer="jack-tiefeng.jia@ibm.com" \
vendor="Zowe" \
version="2.0.2" \
release="2" \
summary="IBM z/OS Jobs UI service" \
description="This Zowe UI component can display jobs running on z/OS"

##################################
# switch context
USER zowe
WORKDIR /component

##################################
# copy files
COPY --chown=zowe:zowe component .
COPY --chown=zowe:zowe component/LICENSE /licenses
3 changes: 2 additions & 1 deletion manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ id: org.zowe.explorer-jes
# Component version is defined in gradle.properties for Gradle project
# Human readable component name
title: JES Explorer
version: 2.0.1
# version will be synced from package.json during build time
version: 2.0.0
# Human readable component description
description: IBM z/OS Jobs UI service
license: EPL-2.0
Expand Down
4 changes: 2 additions & 2 deletions pluginDefinition.prod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"identifier": "org.zowe.explorer-jes",
"apiVersion": "1.0.0",
"pluginVersion": "2.0.0",
"apiVersion": "{{version}}",
"pluginVersion": "{{version}}",
"pluginType": "application",
"webContent": {
"framework": "iframe",
Expand Down