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

alija/task/101 #38

Open
wants to merge 13 commits into
base: alija/feature/webpack
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 116 additions & 25 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@

pipeline {
parameters {
booleanParam(name: 'deploy', defaultValue: true, description: 'Deploy build')
booleanParam(name: 'deploy_io', defaultValue: false, description: 'Deploy build to github.io')
booleanParam(name: 'deploy_io_exchange', defaultValue: false, description: 'Exchange deployed build to github.io with previous commit')
booleanParam(name: 'store', defaultValue: false, description: 'Store build')
booleanParam(name: 'release', defaultValue: false, description: 'Release build')
booleanParam(name: 'release_comment', defaultValue: true, description: 'Add comment to each issue and pull request resolved')
password(name: 'GH_TOKEN', defaultValue: '', description: 'Github user token. Note: don\'t use a password, will be logged to console on error.')
choice(name: 'destination', description: 'Destination folder', choices: ['asterics-web-devlinux/WebACS', 'asterics-web-devwindows/WebACS', 'asterics-web-production/WebACS' ])
choice(name: 'agent', description: 'Agent', choices: ['Linux', 'Win'])
choice(name: 'image', description: 'Docker Image', choices: ['node:10', 'node:11'])
gitParameter(name: 'BRANCH', branchFilter: 'origin.*?/(.*)', defaultValue: 'master', type: 'PT_BRANCH_TAG', useRepository: 'WebACS')
}
triggers {
// pollSCM('H/15 * * * *')
pollSCM('* * * * *')
}
agent none
stages {
stage('Cleanup') {
Expand All @@ -30,6 +41,20 @@ pipeline {
'''
}
}
stage('Prepare: Release/Store') {
when {
anyOf {
equals expected: true, actual: params.release
equals expected: true, actual: params.store
}
}
agent {
label params.agent
}
steps {
sh 'cd dist && zip -r ../WebACS.zip *'
}
}
stage('Test') {
agent {
docker {
Expand All @@ -45,31 +70,97 @@ pipeline {
'''
}
}
stage('Archive') {
agent {
label params.agent
}
steps {
sh 'cd dist && zip -r ../WebACS.zip *'
archiveArtifacts artifacts: 'WebACS.zip', fingerprint: true
}
}
stage('Deploy') {
environment {
SERVER = credentials('server')
}
agent {
label params.agent
}
steps {
sh '''
mkdir build
mv dist build/WebACS
'''
script {
def remote = [ name: 'studyathome', host: 'studyathome.technikum-wien.at', user: env.SERVER_USR, password: env.SERVER_PSW, allowAnyHosts: true ]
sshRemove remote: remote, path: "/var/www/html/${params.destination}", failOnError: false
sshPut remote: remote, from: 'build/WebACS', into: "/var/www/html/${params.destination.replace("/WebACS", "")}"
stage('Output') {
parallel {
stage('Deploy') {
when {
equals expected: true, actual: params.deploy
}
agent {
label params.agent
}
environment {
SERVER = credentials('server')
}
steps {
sh '''
mkdir build
ln -s ../dist build/WebACS
'''
script {
def remote = [ name: 'studyathome', host: 'studyathome.technikum-wien.at', user: env.SERVER_USR, password: env.SERVER_PSW, allowAnyHosts: true ]
sshRemove remote: remote, path: "/var/www/html/${params.destination}", failOnError: false
sshPut remote: remote, from: 'build/WebACS', into: "/var/www/html/${params.destination.replace("/WebACS", "")}"
}
}
}
stage('Deploy: Github IO') {
when {
equals expected: true, actual: params.deploy_io
}
agent {
label params.agent
}
steps {
sh '''
git clone -b gh-pages --single-branch https://github.com/asterics/WebACS.git gh-pages
'''
script {
if (params.deploy_io_exchange) {
sh '''
cd gh-pages
git log
git reset --hard HEAD~1
git log
'''
}
}
sh '''
rm -rf gh-pages/*
cp -r dist/* gh-pages/
cd gh-pages
git add .
git add -u .
git -c user.name='Mr. Jenkins' -c user.email='[email protected]' commit -m 'docs: release WebACS'
git push -f https://[email protected]/asterics/WebACS.git
'''
}
}
stage('Store') {
when {
equals expected: true, actual: params.store
}
agent {
label params.agent
}
steps {
archiveArtifacts artifacts: 'WebACS.zip', fingerprint: true
archiveArtifacts artifacts: 'dist/build.json', fingerprint: true
}
}
stage('Release') {
when {
// branch 'master'
// changeset 'assets'
equals expected: true, actual: params.release
}
agent {
docker {
image params.image
label params.agent
}
}
environment {
GIT_BRANCH = "$BRANCH"
}
steps {
sh '''
git checkout $BRANCH
git pull
yarn release:prepare
yarn release --branch $BRANCH
'''
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ import "./assets/css/webACS.css";

import webACS from "./src/webACS.js";

// import "./node_modules/jquery-ui/ui/"

webACS();
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WebACS",
"version": "3.0.1",
"version": "3.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 3.0.0?
Is this the number of the 'first' version?
And afterwards the number will be set by the semantic versioning library automatically?

"description": "Assistive Technology Rapid Integration and Construction Set",
"main": "index.js",
"repository": "https://github.com/asterics/WebACS.git",
Expand All @@ -10,8 +10,11 @@
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"postbuild": "node src/scripts/logBuild.js",
"test:watch": "cross-env NODE_ENV=test jest --watch",
"test": "cross-env NODE_ENV=test jest"
"test": "cross-env NODE_ENV=test jest",
"release": "semantic-release",
"release:prepare": "yarn add -D semantic-release@15 @semantic-release/commit-analyzer @semantic-release/changelog @semantic-release/exec"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down
61 changes: 61 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const { release_comment } = process.env;
const successComment = release_comment === "true"
? ":tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)"
: false;

module.exports = {
repositoryUrl: "https://github.com/asterics/WebACS",
tagFormat: "v${version}",
plugins: [
[
"@semantic-release/npm",
{
npmPublish: false
// tarballDir: "dist"
}
],
[
"@semantic-release/github",
{
assets: [{ path: "WebACS-v*.zip", label: "AsTeRICS WebACS" }, { path: "dist/build.json", label: "build.json" }],
successComment
}
],
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
releaseRules: [{ type: "docs", scope: "README", release: "patch" }, { type: "major", release: "major" }],
parserOpts: {
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"]
}
}
],
[
"@semantic-release/release-notes-generator",
{
preset: "angular",
parserOpts: {
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
},
writerOpts: {
commitsSort: ["subject", "scope"]
}
}
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
prepareCmd: "node src/scripts/semantic-release/prepare.js ${nextRelease.version} ${options.branch} ${commits.length} ${Date.now()}"
}
]
],
dryRun: false,
ci: false
};
14 changes: 14 additions & 0 deletions src/scripts/logBuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { BRANCH } = process.env;
const { writeFileSync } = require("fs");
const { join } = require("path");
const { execSync } = require("child_process");

const branch = BRANCH || execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).replace("\n", "");
const commitId = execSync("git rev-parse HEAD", { encoding: "utf8" }).replace("\n", "");
const commitUrl = "https://github.com/asterics/WebACS/commit/" + commitId;
const date = Date();

const buildInfo = JSON.stringify({ date, branch, commitId, commitUrl }, null, 4);
console.log("Creating build information:")
console.log(buildInfo);
writeFileSync(join(process.cwd(), "dist/build.json"), buildInfo, "utf8");
13 changes: 13 additions & 0 deletions src/scripts/semantic-release/prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { lstatSync, readdirSync, symlinkSync } = require("fs");

let version = process.argv[2];

/* Search `WebACS.zip` in root folder */
const release = readdirSync(process.cwd())
.filter(e => !lstatSync(e).isDirectory())
.filter(e => e.match(/^WebACS.zip$/));

/* Rename if `WebACS.zip` found */
if (release.length > 0) {
symlinkSync("WebACS.zip", `WebACS-v${version}.zip`);
}