Skip to content

Commit

Permalink
ci: Build-script.
Browse files Browse the repository at this point in the history
Using gitlab-ci for build pipelines.

Signed-off-by: Johannes Tegnér <[email protected]>
  • Loading branch information
Johannestegner committed May 24, 2022
1 parent ad75ae8 commit 4d52ac1
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
stages:
- test
- build
- containerize
- pre-release
- release

test:
stage: test
image: mcr.microsoft.com/dotnet/sdk:6.0
script:
- dotnet restore cc-gen.tests/cc-gen.tests.csproj
- dotnet test
build:
stage: build
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
parallel:
matrix:
- { BUILD_ARCH: "win-x64" }
- { BUILD_ARCH: "linux-x64" }
- { BUILD_ARCH: "linux-musl-x64" }
image: mcr.microsoft.com/dotnet/sdk:6.0
script:
- dotnet restore cc-gen/cc-gen.csproj
- dotnet publish .\cc-gen\cc-gen.csproj -c Release --self-contained true -r ${BUILD_ARCH} -v m --version-suffix ${CI_COMMIT_TAG} -o release/${BUILD_ARCH}
artifacts:
paths:
- release/
expire_in: 1 day

containerize:
stage: containerize
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
image: registry.gitlab.com/jitesoft/dockerfiles/misc:latest
script:
- docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} --build-arg "VERSION=${CI_COMMIT_TAG}" -f cc-gen/Dockerfile .
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
tags:
- jitesoft
- protected
- amd64
- docker

create_release:
stage: pre-release
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
script:
- "cc-gen gen --latest > CHANGELOG.md"
artifacts:
paths:
- CHANGELOG.md
when: on_success
expire_in: 1 hours
tags:
- protected

release:
needs:
- job: create_release
artifacts: true
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
- when: never
script:
- echo "Creating release for ${CI_COMMIT_TAG}"
- release-cli create --name "${CI_COMMIT_TAG}" --description "$(cat CHANGELOG.md)" --tag-name "${CI_COMMIT_TAG}"
tags:
- protected
2 changes: 2 additions & 0 deletions cc-gen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{7E30A818-2
cc-gen.sln = cc-gen.sln
README.md = README.md
LICENSE = LICENSE
.cc-gen = .cc-gen
.gitlab-ci.yml = .gitlab-ci.yml
EndProjectSection
EndProject
Global
Expand Down

0 comments on commit 4d52ac1

Please sign in to comment.