Skip to content

Commit

Permalink
Build with Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
kwkwan committed Aug 8, 2018
1 parent 25512ba commit d8d26e8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
24 changes: 8 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pipeline {
stage("Test and Build") {
environment {
CARGO = "~/.cargo/bin/cargo"
OAUTH = credentials("GitHub")
}
when {
branch 'master'
}
stages {
stage("Debian") {
Expand All @@ -22,7 +26,8 @@ pipeline {
sh '''
LIBC_VERSION=$(ldd --version | head -n1 | sed -r 's/(.* )//')
mkdir -p assets
tar -C target/release -czf assets/riffol-$LIBC_VERSION.tar.gz riffol
tar -C target/release -zcvf assets/riffol-libc-$LIBC_VERSION.tar.gz riffol
ci/release.sh riboseinc/riffol
'''
}
}
Expand All @@ -42,25 +47,12 @@ pipeline {
sh '''
LIBC_VERSION=$(ldd --version | head -n1 | sed -r 's/(.* )//')
mkdir -p assets
tar -C target/release -czf assets/riffol-$LIBC_VERSION.tar.gz riffol
tar -C target/release -zcvf assets/riffol-libc-$LIBC_VERSION.tar.gz riffol
ci/release.sh riboseinc/riffol
'''
}
}
}
}
stage("Upload Assets") {
agent any
when {
branch 'master'
}
environment {
OAUTH = credentials("GitHub")
}
steps {
sh '''
ci/release.sh riboseinc/riffol
'''
}
}
}
}
4 changes: 4 additions & 0 deletions ci/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ RUN useradd -u 1000 docker-user

RUN su - docker-user -c 'curl https://sh.rustup.rs -sSf | sh -s -- -y && ~/.cargo/bin/cargo search nereon'

RUN curl -L -o/usr/bin/jq \
https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \
&& chmod +x /usr/bin/jq

RUN git clone https://github.com/vstakhov/libucl.git \
&& cd libucl \
&& ./autogen.sh \
Expand Down
4 changes: 4 additions & 0 deletions ci/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ RUN useradd -u 1000 docker-user && \

RUN su - docker-user -c 'curl https://sh.rustup.rs -sSf | sh -s -- -y && ~/.cargo/bin/cargo search nereon'

RUN curl -L -o/usr/bin/jq \
https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \
&& chmod +x /usr/bin/jq

RUN git clone https://github.com/vstakhov/libucl.git \
&& cd libucl \
&& ./autogen.sh \
Expand Down
8 changes: 6 additions & 2 deletions ci/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ release_id=$(
# create a release if none already for this version
if [ -z $release_id ]; then
echo "Creating release for $version"
release_id=$(curl -s -X POST -d '{"tag_name":"$version"}' $release?access_token=$OAUTH | jq -r '"\(.id)"' 2>/dev/null)

release_id=$(curl -s -X POST -d '{"tag_name":"'$version'"}' $release?access_token=$OAUTH | jq -r '"\(.id)"' 2>/dev/null)

echo "Release ID: $release_id"

Expand All @@ -50,8 +51,11 @@ fi
# get upload url
upload=$(curl -s $release/$release_id?access_token=$OAUTH | jq -r '"\(.upload_url)"' | cut -d'{' -f1)
for i in assets/*.tar.gz; do
echo "Asset: $i"

if [ -f $i ]; then
asset_name=$(basename $i)
echo "Asset name: $asset_name"
asset_id=$(
curl -s $release/$release_id/assets?access_token=$OAUTH \
| jq -r '.[] | "\(.name) \(.id)"' \
Expand All @@ -64,6 +68,6 @@ for i in assets/*.tar.gz; do
fi
# upload asset
echo "Uploading $asset_name asset"
curl -s -X POST -H "Content-type: application/gzip" -d@- "$upload?name=$asset_name&access_token=$OAUTH" <$i >/dev/null
curl -X POST -H "Content-Type: application/tar+gzip" --data-binary @"$i" "$upload?name=$asset_name&access_token=$OAUTH" >/dev/null
fi
done

0 comments on commit d8d26e8

Please sign in to comment.