fuzzyworld

template / commit

Trying to use releaser from gitlab CI.

c439343160dba433bde2d6f01d0276a0d7c4deaf · Pavel Safronov · 2022-11-16 00:09:36 -0800 · parents b3de39c0ffa8

Trying to use releaser from gitlab CI.
 .gitlab-ci.yml | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ec32fd8..a932d4e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,7 +21,7 @@ image: golang:1.19
 stages:          # List of stages for jobs, and their order of execution
   - build
   - test
-  - deploy
+  - release
 
 build-job:       # This job runs in the build stage, which runs first.
   stage: build
@@ -48,9 +48,28 @@ lint-test-job:   # This job also runs in the test stage.
     - make lint
     - echo "No lint issues found."
 
-deploy-job:      # This job runs in the deploy stage.
-  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
-  environment: production
-  script:
-    - echo "Deploying application..."
-    - echo "Application successfully deployed."
+release:
+  stage: release
+  image: docker:stable
+  services:
+    - docker:dind
+
+  variables:
+    # Disable shallow cloning so that goreleaser can diff between tags to
+    # generate a changelog.
+    GIT_DEPTH: 0
+
+  # Only run this release job for tags, not every commit (for example).
+  only:
+    refs:
+      - tags
+
+  script: |
+    # GITLAB_TOKEN is needed to create GitLab releases.
+    # DOCKER_* are needed to push Docker images.
+    docker run --rm --privileged \
+      -v $PWD:/go/src/gitlab.com/YourGitLabUser/YourGitLabRepo \
+      -w /go/src/gitlab.com/YourGitLabUser/YourGitLabRepo \
+      -v /var/run/docker.sock:/var/run/docker.sock \
+      -e GITLAB_TOKEN \
+      goreleaser/goreleaser release --rm-dist