Skip to content

Commit 7685aa3

Browse files
feat(fork): manage release of fork (#11)
covers [DEV-146](https://bonitasoft.atlassian.net/browse/DEV-146)
1 parent 294c492 commit 7685aa3

File tree

6 files changed

+233
-2
lines changed

6 files changed

+233
-2
lines changed

.github/workflows/release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release angular.js
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: new version to release ([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)
8+
default: 1.3.18-patched.01
9+
required: true
10+
11+
jobs:
12+
createGithubRelease:
13+
name: Create release
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout main
17+
uses: actions/checkout@v3
18+
- name: Checkout bower-angular
19+
uses: actions/checkout@v3
20+
with:
21+
repository: bonitasoft/bower-angular
22+
path: 'bower-angular'
23+
token: ${{ secrets.BONITA_CI_PAT }}
24+
- name: Config git
25+
run: |
26+
git config --global user.email "angular.js-bot@users.noreply.github.com"
27+
git config --global user.name "angular.js-bot"
28+
git config --global pull.rebase true
29+
- name: Build Setup
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: '16'
33+
cache: 'npm'
34+
- name: Release
35+
run: |
36+
bash ${GITHUB_WORKSPACE}/scripts/github-actions/release.sh --git-push-dryrun=false --version-number=${{ github.event.inputs.version }}
37+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ libpeerconnection.log
2020
npm-debug.log
2121
/tmp/
2222
/scripts/bower/bower-*
23+
bower-angular/

scripts/github-actions/publish.sh

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
# Script for updating the Angular bower repos from current local build.
4+
5+
echo "#################################"
6+
echo "#### Update bower ###############"
7+
echo "#################################"
8+
9+
ARG_DEFS=(
10+
"--action=(prepare|publish)"
11+
# the version number of the release.
12+
# e.g. 1.2.12 or 1.2.12-rc.1
13+
"--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)"
14+
)
15+
16+
function init {
17+
BOWER_ANGULAR_DIR=$(resolveDir ../../bower-angular)
18+
BUILD_DIR=$(resolveDir ../../build)
19+
NEW_VERSION=$VERSION_NUMBER
20+
if [ -z $NEW_VERSION ]
21+
then
22+
NEW_VERSION=$(cat $BUILD_DIR/version.txt)
23+
fi
24+
# get the npm dist-tag from a custom property (distTag) in package.json
25+
# DIST_TAG=$(readJsonProp "package.json" "distTag")
26+
}
27+
28+
29+
function prepare {
30+
#
31+
# move the files from the build
32+
#
33+
if [ -f $BUILD_DIR/angular.js ] # ignore i18l
34+
then
35+
echo "-- Updating files in bower-angular"
36+
cp $BUILD_DIR/angular.* $BOWER_ANGULAR_DIR
37+
fi
38+
39+
# move i18n files
40+
# cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/
41+
42+
# move csp.css
43+
cp $BUILD_DIR/angular-csp.css $BOWER_ANGULAR_DIR
44+
45+
46+
#
47+
# Run local precommit script if there is one
48+
#
49+
if [ -f $BOWER_ANGULAR_DIR/precommit.sh ]
50+
then
51+
echo "-- Running precommit.sh script for bower-angular"
52+
cd $BOWER_ANGULAR_DIR
53+
./precommit.sh
54+
cd $SCRIPT_DIR
55+
fi
56+
57+
58+
#
59+
# update bower.json
60+
# tag each repo
61+
#
62+
echo "-- Updating version in bower-angular to $NEW_VERSION"
63+
cd $BOWER_ANGULAR_DIR
64+
replaceJsonProp "bower.json" "version" ".*" "$NEW_VERSION"
65+
replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION"
66+
replaceJsonProp "package.json" "version" ".*" "$NEW_VERSION"
67+
replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION"
68+
69+
git add -A
70+
71+
echo "-- Committing and tagging bower-angular"
72+
git commit -m "v$NEW_VERSION"
73+
git tag v$NEW_VERSION
74+
cd $SCRIPT_DIR
75+
}
76+
77+
function publish {
78+
echo "-- Pushing bower-angular"
79+
cd $BOWER_ANGULAR_DIR
80+
git push origin master
81+
git push origin v$NEW_VERSION
82+
83+
# don't publish every build to npm
84+
# if [ "${NEW_VERSION/+sha}" = "$NEW_VERSION" ] ; then
85+
# echo "-- Publishing to npm as $DIST_TAG"
86+
# npm publish --tag=$DIST_TAG
87+
# fi
88+
89+
cd $SCRIPT_DIR
90+
}
91+
92+
source $(dirname $0)/../utils.inc

scripts/github-actions/release.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# tags the current commit as a release and publishes all artifacts to
4+
# the different repositories.
5+
# Note: This will also works if the commit is in the past!
6+
7+
echo "#################################"
8+
echo "#### cut release ############"
9+
echo "#################################"
10+
11+
ARG_DEFS=(
12+
# require the git dryrun flag so the script can't be run without
13+
# thinking about this!
14+
"--git-push-dryrun=(true|false)"
15+
# the version number of the release.
16+
# e.g. 1.2.12 or 1.2.12-rc.1
17+
"--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)"
18+
)
19+
20+
function init {
21+
if [[ ! $VERBOSE ]]; then
22+
VERBOSE=false
23+
fi
24+
VERBOSE_ARG="--verbose=$VERBOSE"
25+
}
26+
27+
function build {
28+
# ./set-node-version.sh
29+
cd ../..
30+
31+
npm install -g grunt-cli@0.1.13
32+
npm i
33+
npm i
34+
grunt package
35+
36+
./check-size.sh
37+
38+
cd $SCRIPT_DIR
39+
}
40+
41+
function phase {
42+
ACTION_ARG="--action=$1"
43+
./tag-release.sh $ACTION_ARG $VERBOSE_ARG\
44+
--version-number=$VERSION_NUMBER
45+
46+
if [[ $1 == "prepare" ]]; then
47+
# The build requires the tag to be set already!
48+
build
49+
fi
50+
51+
./publish.sh $ACTION_ARG --version-number=$VERSION_NUMBER $VERBOSE_ARG
52+
}
53+
54+
function run {
55+
# First prepare all scripts (build, commit, tag, ...),
56+
# so we are sure everything is all right
57+
phase prepare
58+
# only then publish to github
59+
phase publish
60+
}
61+
62+
source $(dirname $0)/../utils.inc

scripts/github-actions/tag-release.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Tags a release
4+
# so that travis can do the actual release.
5+
6+
echo "#################################"
7+
echo "## Tag angular.js for a release #"
8+
echo "#################################"
9+
10+
ARG_DEFS=(
11+
"--action=(prepare|publish)"
12+
# the version number of the release.
13+
# e.g. 1.2.12 or 1.2.12-rc.1
14+
"--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)"
15+
)
16+
17+
function checkVersionNumber() {
18+
BRANCH_PATTERN=$(readJsonProp "package.json" "branchVersion")
19+
if [[ $VERSION_NUMBER != $BRANCH_PATTERN ]]; then
20+
echo "version-number needs to match $BRANCH_PATTERN on this branch"
21+
usage
22+
fi
23+
}
24+
25+
function init {
26+
cd ../..
27+
checkVersionNumber
28+
TAG_NAME="v$VERSION_NUMBER"
29+
}
30+
31+
function prepare() {
32+
git tag "$TAG_NAME" -m "chore(release): $TAG_NAME codename($TAG_NAME)"
33+
}
34+
35+
function publish() {
36+
# push the tag to github
37+
git push origin $TAG_NAME
38+
}
39+
40+
source $(dirname $0)/../utils.inc

scripts/utils.inc

+1-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ function replaceJsonProp {
209209

210210
# replaceInFile(file, findPattern, replacePattern)
211211
function replaceInFile {
212-
sed -i .tmp -E "s/$2/$3/" $1
213-
rm $1.tmp
212+
sed -i -E "s/$2/$3/" $1
214213
}
215214

216215
# resolveDir(relativeDir)

0 commit comments

Comments
 (0)