ci: add a release pipeline
This commit adds a release pipeline for publishing my CV online to the project's release page and also privately to a mounted volume on my personal machine. The release pipeline is triggered for every tagged commit that uses the date versioning scheme (e.g. 2021.09.21). Changes include: - added tags to all jobs so private runners are used. - added a build stage. - added a build job to build the CV for merge requests. - added a build job to build the CV for the release pipeline. - the build job for the release pipeline adds the CV to an artifacts that expire after 1 year. - created a publish job for publishing the CV online to the project's release page. - created a publish job for publishing the CV privately to a mounted volume on the private runner. - small updates in the README. - removed the CV file from the repository. - removed the job that publishes the CV PDF file to the master branch.
This commit is contained in:
parent
b6d1820ebd
commit
0dac49356c
5 changed files with 102 additions and 35 deletions
|
@ -1,11 +1,13 @@
|
|||
---
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- publish
|
||||
|
||||
variables:
|
||||
IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_PATH}/cv-builder
|
||||
IMAGE_TAG: ${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}
|
||||
RELEASE_CV_FILENAME: cv-DanAnglin-${CI_COMMIT_REF_NAME}.pdf
|
||||
|
||||
include:
|
||||
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
||||
|
|
|
@ -5,65 +5,127 @@
|
|||
.use-cv-builder:
|
||||
image: ${IMAGE_NAME}:master-cb8a29c7
|
||||
|
||||
.cv-test-rules:
|
||||
.cv-default-job-rules:
|
||||
rules:
|
||||
- changes:
|
||||
- "docker/Dockerfile"
|
||||
when: never
|
||||
- when: always
|
||||
|
||||
.cv-publish-rules:
|
||||
.cv-publish-job-rules:
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_PATH == "dananglin/cv"'
|
||||
- if: '$CI_COMMIT_REF_NAME =~ /^[0-9]{4}(.[0-9]{2}){2}$/ && $CI_PROJECT_PATH == "dananglin/cv"'
|
||||
when: always
|
||||
- changes:
|
||||
- "docker/Dockerfile"
|
||||
when: never
|
||||
|
||||
.default-tags:
|
||||
tags:
|
||||
- dananglin-general
|
||||
|
||||
.release-tags:
|
||||
tags:
|
||||
- dananglin-cv-release
|
||||
|
||||
#------------------------------------#
|
||||
# Visible jobs for CV build pipeline #
|
||||
#------------------------------------#
|
||||
|
||||
test:spellcheck:
|
||||
before_script:
|
||||
- apt-get update
|
||||
- apt-get -y install aspell aspell-en
|
||||
extends:
|
||||
- .cv-test-rules
|
||||
- .cv-default-job-rules
|
||||
- .default-tags
|
||||
- .use-cv-builder
|
||||
stage: test
|
||||
script:
|
||||
- go run mage.go spellcheck
|
||||
stage: test
|
||||
|
||||
test:pdf:
|
||||
extends:
|
||||
- .cv-default-job-rules
|
||||
- .default-tags
|
||||
- .use-cv-builder
|
||||
script:
|
||||
- go run mage.go pdf
|
||||
stage: test
|
||||
|
||||
build:pdf:
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
expire_in: "30 minutes"
|
||||
paths:
|
||||
- __output/cv.pdf
|
||||
extends:
|
||||
- .default-tags
|
||||
- .use-cv-builder
|
||||
- .cv-test-rules
|
||||
stage: test
|
||||
needs:
|
||||
- job: "test:spellcheck"
|
||||
artifacts: false
|
||||
- job: "test:pdf"
|
||||
artifacts: false
|
||||
rules:
|
||||
- if: '$CI_MERGE_REQUEST_IID'
|
||||
when: always
|
||||
script:
|
||||
- go run mage.go pdf
|
||||
stage: build
|
||||
|
||||
publish:pdf:
|
||||
build:pdf-for-publish:
|
||||
artifacts:
|
||||
expire_in: "1 year"
|
||||
name: cv-DanAnglin-${CI_COMMIT_REF_NAME}
|
||||
paths:
|
||||
- ${RELEASE_CV_FILENAME}
|
||||
- build_job_id
|
||||
extends:
|
||||
- .cv-publish-job-rules
|
||||
- .default-tags
|
||||
- .use-cv-builder
|
||||
- .cv-publish-rules
|
||||
before_script:
|
||||
- eval $(ssh-agent -s)
|
||||
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||
- chmod 0400 ~/.ssh/known_hosts
|
||||
- git remote set-url origin git@gitlab.com:${CI_PROJECT_PATH}.git
|
||||
- git config --global user.email "${GITLAB_USER_EMAIL}"
|
||||
- git config --global user.name "${GITLAB_USER_NAME}"
|
||||
stage: publish
|
||||
needs:
|
||||
- job: "test:spellcheck"
|
||||
artifacts: false
|
||||
- job: "test:pdf"
|
||||
artifacts: false
|
||||
script:
|
||||
- go run mage.go pdf
|
||||
- git checkout master
|
||||
- git add __output/cv.pdf
|
||||
- 'git commit -m "auto: [skip ci] update CV."'
|
||||
- git push origin master
|
||||
- mv __output/cv.pdf ${RELEASE_CV_FILENAME}
|
||||
- echo "${CI_JOB_ID}" > build_job_id
|
||||
stage: build
|
||||
|
||||
publish:pdf:online:
|
||||
before_script:
|
||||
- export BUILD_JOB_ID=$( cat build_job_id )
|
||||
extends:
|
||||
- .cv-publish-job-rules
|
||||
- .release-tags
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:v0.3.0
|
||||
needs:
|
||||
- job: "build:pdf-for-publish"
|
||||
artifacts: true
|
||||
script:
|
||||
- 'echo "Publishing CV for release ${CI_COMMIT_REF_NAME}"'
|
||||
- >
|
||||
release-cli create --name "CV - ${CI_COMMIT_REF_NAME}"
|
||||
--description "CV published with the release-cli tool for version ${CI_COMMIT_REF_NAME}"
|
||||
--tag-name "${CI_COMMIT_REF_NAME}"
|
||||
--ref "${CI_COMMIT_REF_NAME}"
|
||||
--assets-links-name "${RELEASE_CV_FILENAME}"
|
||||
--assets-links-url "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/jobs/${BUILD_JOB_ID}/artifacts/${RELEASE_CV_FILENAME}"
|
||||
stage: "publish"
|
||||
variables:
|
||||
GIT_STRATEGY: "none"
|
||||
|
||||
# Private releases rebuilds the CV with the extra details.
|
||||
publish:pdf:private:
|
||||
extends:
|
||||
- .cv-publish-job-rules
|
||||
- .release-tags
|
||||
- .use-cv-builder
|
||||
needs:
|
||||
- job: "test:spellcheck"
|
||||
artifacts: false
|
||||
- job: "test:pdf"
|
||||
artifacts: false
|
||||
script:
|
||||
- go run mage.go pdf
|
||||
- mv __output/cv.pdf ${CV_DEPLOY_DIR}/${RELEASE_CV_FILENAME}
|
||||
stage: publish
|
||||
variables:
|
||||
CV_DEPLOY_DIR: "/CV"
|
||||
CV_CONTACT_PHONE: $RELEASE_CV_CONTACT_PHONE
|
||||
|
|
|
@ -21,9 +21,12 @@
|
|||
|
||||
.docker-test-rules:
|
||||
rules:
|
||||
- changes:
|
||||
- if: '$CI_COMMIT_BRANCH'
|
||||
changes:
|
||||
- "docker/Dockerfile"
|
||||
when: always
|
||||
- if: '$CI_COMMIT_REF_NAME =~ /^[0-9]{4}(.[0-9]{2}){2}$/'
|
||||
when: never
|
||||
|
||||
.docker-publish-pre-post:
|
||||
stage: publish
|
||||
|
|
|
@ -22,7 +22,7 @@ Support for other formats such as HTML will be available soon.
|
|||
|
||||
### View/Download the CV
|
||||
|
||||
The latest build of the generated PDF document can be downloaded [here](__output/cv.pdf)
|
||||
The latest build of the generated PDF document can be downloaded from the [release](https://gitlab.com/dananglin/cv/-/releases) page of the project in GitLab.
|
||||
|
||||
## Dependencies
|
||||
|
||||
|
@ -82,7 +82,7 @@ To use the image follow the steps below:
|
|||
The PDF document can be generated by running the following command:
|
||||
|
||||
```bash
|
||||
$ make pdf
|
||||
$ go run mage.go pdf
|
||||
```
|
||||
|
||||
The PDF generation is completed in two steps:
|
||||
|
|
BIN
__output/cv.pdf
BIN
__output/cv.pdf
Binary file not shown.
Loading…
Reference in a new issue