Sign inSign up

alexeysunshine/builder

By alexeysunshine

•Updated over 2 years ago

semantic-release + ssh-client

Image
0

409

alexeysunshine/builder repository overview

The image is

FROM node:22.2.0-alpine3.20

RUN apk add --no-cache \
  openssh-client \
  ca-certificates \
  curl \
  bash

RUN npm i -g semantic-release @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/gitlab @semantic-release/git @semantic-release/release-notes-generator conventional-changelog-conventionalcommits @semantic-release/exec

.gitlab-ci.yml is

stages:          # List of stages for jobs, and their order of execution
  - release

Release:
  when: manual
  image: alexeysunshine/builder
  stage: release
  script:
    - chmod +x ./build.sh
    - npx semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && ($CI_COMMIT_TITLE !~ /^RELEASE:.+$/)
      when: always
    - when: manual
      allow_failure: true

release.config.mjs

/**
 * @type {import('semantic-release').GlobalConfig}
 */
export default {
  "branches": [
    "main"
  ],
  "ci": true,
  "debug": true,
  "dryRun": false,
  "tagFormat": "v${version}",
  "preset": "conventionalcommits",
  "gitlabUrl": "https://gitlab.com/",
  "plugins": [
    "@semantic-release/changelog",
    "@semantic-release/commit-analyzer",
    "@semantic-release/git",
    // "@semantic-release/release-notes-generator",
    "@semantic-release/gitlab",
    "@semantic-release/exec",
  ],
  "verifyConditions": [
    "@semantic-release/changelog",
    "@semantic-release/git",
    "@semantic-release/gitlab"
  ],
  "analyzeCommits": [
    {
      "path": "@semantic-release/commit-analyzer"
    }
  ],
  // "generateNotes": [
  //   {
  //     "path": "@semantic-release/release-notes-generator",
  //     "writerOpts": {
  //       "groupBy": "type",
  //       "commitGroupsSort": "title",
  //       "commitsSort": "header"
  //     },
  //     "linkCompare": true,
  //     "linkReferences": true
  //   }
  // ],
  "prepare": [
    {
      "path": "@semantic-release/changelog"
    },
    {
      "path": "@semantic-release/git",
      "message": "RELEASE: ${nextRelease.version}",
      "assets": [
        "CHANGELOG.md"
      ]
    }
  ],
  "publish": [
    {
      "path": "@semantic-release/gitlab",
      "assets": [
        { "path": "dummy.jpg", "label": "v${nextRelease.version}.zip" }
      ]
    },
    {
      "path": "@semantic-release/exec",
      "publishCmd": "./build.sh ${nextRelease.version} ${branch.name} ${commits.length} ${Date.now()}"
    }
  ],
  "success": false,
  "fail": false
}

build.sh

#!/bin/bash
echo "example dummy build"
touch "./release.txt"
echo "just an example version is $1" >> ./release.txt
echo "branch name is $2"  >> ./release.txt
echo "commits length is $3" >> ./release.txt
echo "date $4" >> ./release.txt
curl -v -F "document=@./release.txt" -F parse_mode='HTML' --form-string "caption=<code>bundle $1</code>" "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHAT_ID}"

Tag summary

Content type

Image

Digest

sha256:798a08278…

Size

102.5 MB

Last updated

over 2 years ago

docker pull alexeysunshine/builder