Skip to content
Snippets Groups Projects

Merging final pip in main

Closed Isabelle Josephine Karal requested to merge s91190/app-service:stable into main
1 file
+ 7
5
Compare changes
  • Side-by-side
  • Inline
+ 65
7
workflow:
rules:
- if: >-
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: 'always'
- when: 'never'
#pip wird nur ausgeführt, wenn ein merge request gibt
- if: $CI_PIPELINE_SOURCE == "merge_request_event" #https://docs.gitlab.com/ee/ci/yaml/workflow.html
when: always
# und wenn es ein push auf stable gibt
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "stable" #https://docs.gitlab.com/ee/ci/yaml/workflow.html
when: always
- when: never
stages:
- build
- test
- release
job_build:
stage: build
rules:
- if: $CI_COMMIT_REF_NAME =~ /stable/ #https://docs.gitlab.com/ee/ci/yaml/workflow.html
when: always
before_script:
- mkdir -p ./artifacts
script:
- apk add go
- go get -t ./...
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./artifacts/webservice-linuxAMD ./*.go #https://www.digitalocean.com/community/tutorials/building-go-applications-for-different-operating-systems-and-architectures, https://stackoverflow.com/questions/49860018/what-are-the-goos-and-goarch-values-to-build-go-executable-file-on-gcp-container
- GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ./artifacts/webservice-DarwinAMD ./*.go
- GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ./artifacts/webservice-WindowsAMD.exe ./*.go
artifacts:
paths:
- ./artifacts
job_test:
stage: test
rules:
#tests werden immer ausgeführt, wenn es ein push oder ein merge request gibt
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event" #https://docs.gitlab.com/ee/ci/yaml/workflow.html
when: always
script:
- apk add go #image: mirror.gcr.io/library/golang:1.21 das image würde das erneute installieren der go Umgebung ersetzten
- go get -t ./...
- go test -race -v ./...
job_release:
stage: release
image: ubuntu:22.04
rules:
- if: $CI_COMMIT_BRANCH == "stable" || $CI_COMMIT_REF_NAME =~ /stable/ #https://docs.gitlab.com/ee/ci/variables/predefined_variables.html, https://docs.gitlab.com/ee/ci/yaml/#workflow
when: always
dependencies: #https://docs.gitlab.com/ee/ci/yaml/#dependencies
- job_build
before_script:
- apt update
- apt install -y ca-certificates curl
- update-ca-certificates
- export version="${CI_COMMIT_SHA}" #https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
script: #https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
- |
for artifact in ./artifacts/*; do
chmod +x "${artifact}"
curl \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${artifact} \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/artifacts/${version}/"
done
job_trigger-pipeline:
trigger:
project: 'fb6-wp11-devops/webservice-build-and-publish'
Loading