Starter Pipeline with SemVer

Concourse Pipeline with Semantic Versioning (SemVer)

Semver Starter Pipeline

  • code-repo - repo with the code to build and test
  • artifact - s3 location to which a built tarball will go
  • version - s3 file containing the version number associated with the code

This pipeline

  • "performs a build" and, if the build is successful, the pipeline bumps its patch-level semver number
  • creates a tarball with the build artifact and includes the semver in the name
  • uploads the resulting tarball to S3
resources:
- name: version
type: semver
source:
driver: s3
initial_version: 0.0.0
access_key_id: ((aws_access))
secret_access_key: ((aws_secret))
bucket: trullla-artifacts
key: semver-example/version
- name: code-repo
type: git
source:
branch: master
private_key: ((deploy_key))
uri: git@gitlab.com:myrepo/ci-repo.git
- name: artifact
type: s3
source:
access_key_id: ((aws_access))
secret_access_key: ((aws_secret))
bucket: trullla-artifacts
regexp: mypackage/mypackage-(.*).tar.gz
region_name: ((aws_region))
jobs:
- name: build
plan:
- get: code-repo
- get: version
params:
bump: patch
- task: build
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
params:
PACKAGE_NAME: mypackage
inputs:
- name: code-repo
- name: version
run:
path: /bin/sh
args:
- -c
- |
set -e
cd code-repo
# do the building, e.g.
mkdir build
touch build/output
cd -
- put: version
params: {file: version/version}
- name: package
plan:
- get: version
passed: [ build ]
- get: code-repo
trigger: true
passed: [ build ]
- task: build
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
params:
PACKAGE_NAME: mypackage
inputs:
- name: code-repo
- name: version
outputs:
- name: tarball
run:
path: /bin/sh
args:
- -c
- |
set -e
VERSION="$(cat version/version)"
PACKAGE="${PACKAGE_NAME}-${VERSION}"
cd code-repo
# do the building, e.g.
mkdir build
cp *.* build
cd -
cp -a code-repo/build "${PACKAGE}"
tar czf tarball/"${PACKAGE}.tar.gz" "${PACKAGE}"
- put: artifact
params:
file: tarball/*.tar.gz