Upload artefacts from CircleCI to GitHub

Karikevinod
1 min readSep 22, 2020

This article will guide you through, how you could upload the generated artefacts from CircleCI to GitHub. I am using a spring-boot project here.

Chain: Git Tag -> GitHub -> CircleCI ->GitHub

When a release is being made using git tags, you might need to store the artefacts. So, the basic problem is — the artefact is built from CI server and not from GitHub, so you need to few additional steps in-order to achieve this.

Below is the snippet which does the job. jdk 8 docker executor.

- run: export TERM=xterm && ./gradlew bootJar
- run: ls build/libs/
- run: sudo apt-get -y -qq update
- run: sudo apt-get -y install curl
- run: curl -0 https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz --output go1.13.8.linux-amd64.tar.gz
- run: tar -xvf go1.13.8.linux-amd64.tar.gz
- run: sudo mv go /usr/local
- run:
name: Set env Vars
command: |
echo 'export export GOPATH="$HOME/go"' >> $BASH_ENV
echo 'export PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"' >> $BASH_ENV
source $BASH_ENV
- run: go get -u github.com/tcnksm/ghr
- run: ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace `git describe --tags` ./build/libs/

Note: Create a personal access token from GitHub and add it as variable in CircleCI.

--

--

Karikevinod

Start-up and tech enthusiast. I write about Tech, Devops and anything related.