-
Notifications
You must be signed in to change notification settings - Fork 2
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
sabicalija
wants to merge
13
commits into
alija/feature/webpack
Choose a base branch
from
alija/task/101
base: alija/feature/webpack
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
alija/task/101 #38
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
161bba6
feat(release): setup complete release preparation and semantic-release
sabicalija 2a6c7d8
fix(release): correct assets name, adapt build.json creation
sabicalija 9b1ec64
build.json: refactor conditional assignment, remove ternary operator
sabicalija 3a0b754
Jenkinsfile: add debug output
sabicalija ebcf00e
release: correct zip path comment
sabicalija bd26abb
Jenkinsfile: change mv to ln
sabicalija c28570e
Jenkinsfile: add build.json artifact
sabicalija 32d35b1
feat(release): deploy to github.io, optionally comment on closed issu…
sabicalija 5be4d5b
Jenkinsfile: git add deleted files on release to github.io
sabicalija 8808310
Jenkinsfile: uncomment test stage, add debug output of sematic-releas…
sabicalija 51dadb3
release: change debug output
sabicalija 9cb5307
release: change ternary condition evaluation
sabicalija d666af7
release: remove debug output, finalize script
sabicalija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') { | ||
|
@@ -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 { | ||
|
@@ -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 | ||
''' | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?