Skip to content

Commit 77f8bbb

Browse files
committed
Re-add files to build on local Jenkins
1 parent 66c3f26 commit 77f8bbb

File tree

5 files changed

+137
-6
lines changed

5 files changed

+137
-6
lines changed

bin/build_jenkins.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
4+
readonly branch=${branch:?"which branch to use"}
5+
6+
main() {
7+
echo "### Releasing VimR started"
8+
9+
pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
10+
11+
git submodule update --init
12+
13+
./bin/set_new_versions.sh
14+
15+
# commit and push the tag
16+
# get the marketing version to be used as tag
17+
source release.spec.sh
18+
19+
if [[ "${is_snapshot}" == true ]]; then
20+
tag_name="snapshot/${bundle_version}"
21+
else
22+
tag_name="${marketing_version}-${bundle_version}"
23+
fi
24+
echo "### Using ${tag_name} as tag name"
25+
git commit -am "Bump version to ${tag_name}"
26+
git tag -am "${tag_name}"
27+
git push
28+
git push origin "${tag_name}"
29+
30+
echo "### Store release notes"
31+
echo "${release_notes}" > release-notes.temp.md
32+
33+
echo "### Build VimR"
34+
35+
# FOR DEV
36+
export create_gh_release=false
37+
export upload=false
38+
39+
release_spec_file=release.spec.sh ./bin/build_release.sh
40+
41+
if [[ "${create_gh_release}" == false ]]; then
42+
echo "### No github release, so exiting after building"
43+
exit 0
44+
fi
45+
46+
echo "### Commit appcast"
47+
if [[ "${update_appcast}" == true ]]; then
48+
if [[ "${is_snapshot}" == false ]]; then
49+
cp appcast.xml appcast_snapshot.xml
50+
fi
51+
52+
git commit appcast* -m "Update appcast"
53+
git push
54+
fi
55+
56+
popd >/dev/null
57+
58+
echo "### Releasing VimR ended"
59+
}
60+
61+
main
62+

bin/build_release.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ main() {
128128
prepare_bin
129129
build_release
130130

131-
if [[ "${create_gh_release}" == true ]]; then
132-
create_gh_release
131+
if [[ "${create_gh_release}" == false ]]; then
132+
echo "### No github release, exiting"
133+
exit 0
133134
fi
134135

136+
create_gh_release
137+
135138
if [[ "${upload}" == true ]]; then
136139
# Give GitHub some time.
137140
sleep 5

bin/set_new_versions.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ declare -r -x github_release_name=${github_release_name}
6363
declare -r -x release_notes=\$(cat release-notes.temp.md)
6464
6565
# Add release notes to release-notes.temp.md and issue
66-
# create_gh_release=true upload=true update_appcast=true release_spec_file=${bundle_version}-${version_marker}.sh ./bin/build_release.sh
66+
# create_gh_release=true upload=true update_appcast=true release_spec_file=release.spec.sh ./bin/build_release.sh
6767
END
6868
)
6969
readonly output
7070

7171
local output_exec
7272
output_exec=$(cat <<-END
73-
create_gh_release=true upload=true update_appcast=true release_spec_file=${bundle_version}-${version_marker}.sh ./bin/build_release.sh
73+
create_gh_release=true upload=true update_appcast=true release_spec_file=release.spec.sh ./bin/build_release.sh
7474
END
7575
)
7676
readonly output_exec
7777

7878
echo "Release notes" > release-notes.temp.md
79-
echo "${output}" > "${bundle_version}-${version_marker}.sh"
79+
echo "${output}" > "release.spec.sh"
8080
echo "${output_exec}" > "build_release.temp.sh"
8181
chmod +x "build_release.temp.sh"
8282

@@ -85,7 +85,7 @@ END
8585
echo ""
8686
echo "### Use the following to build a release:"
8787
echo ""
88-
echo "release_spec_file=${bundle_version}-${version_marker}.sh \\"
88+
echo "release_spec_file=release.spc.sh \\"
8989
echo "create_gh_release=true upload=true update_appcast=true \\"
9090
echo "./bin/build_release.sh"
9191
echo ""

ci/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
* Install Jenkins (via brew)
2+
* Install plugins
3+
- Job DSL
4+
- AnsiColor
5+
* Set the `git` binary in *Manage Jenkins* -> *Global Tool Configuration*
6+
* Set `PATH` for Jenkins (necessary for e.g. `git-lfs`) in *Manage Jenkins* -> *Configure System* -> *Global properties* -> *Environment variables"
7+
* Add a free style job `vimr_setup_jobs` with one step to process a Job DSL file at `ci/create_build_job.groovy`.
8+
- Approve script at *Manager Jenkins* -> *In-process Script Approval*.
9+
10+
---
11+
12+
To test the job creation using local git repository, use `file:///Users/.../vimr-repo` as repository and add "-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true" to `/opt/homebrew/opt/jenkins/bin/jenkins`:
13+
14+
```bash
15+
#!/bin/bash
16+
export JAVA_HOME="${JAVA_HOME:-/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home}"
17+
exec "${JAVA_HOME}/bin/java" "-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true" "-jar" "/opt/homebrew/Cellar/jenkins/2.435/libexec/jenkins.war" "$@"
18+
```
19+

ci/create_build_job.groovy

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Install the following plugins in addition to recommended plugins when installing Jenkins
2+
// - Job DSL
3+
// - AnsiColor
4+
5+
def buildSnapshotJob = freeStyleJob('vimr_build')
6+
7+
buildSnapshotJob.with {
8+
description 'Builds a new snapshot or a new release'
9+
10+
logRotator {
11+
numToKeep(10)
12+
}
13+
14+
parameters {
15+
stringParam('marketing_version', null, 'Eg "0.34.0". If "is_snapshot" is unchecked, you have to enter this.')
16+
booleanParam('is_snapshot', true)
17+
stringParam('branch', 'master', 'Branch to build; defaults to master')
18+
textParam('release_notes', null, 'Release notes')
19+
booleanParam('create_gh_release', false, 'Publish this release to Github?')
20+
booleanParam('upload', false, 'Upload VimR to Github?')
21+
booleanParam('update_appcast', false)
22+
}
23+
24+
scm {
25+
git {
26+
remote {
27+
url('[email protected]:qvacua/vimr.git')
28+
}
29+
branch('*/${branch}')
30+
}
31+
}
32+
33+
wrappers {
34+
colorizeOutput()
35+
}
36+
37+
steps {
38+
shell('./bin/build_jenkins.sh')
39+
}
40+
41+
publishers {
42+
archiveArtifacts {
43+
pattern('build/Build/Products/Release/**')
44+
onlyIfSuccessful()
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)