1.4.1 • Published 11 months ago

semantic-release-space v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

semantic-release-space

semantic-release plugin to publish a JetBrains Space Deployment.

npm latest version npm next version npm beta version

StepDescription
verifyConditionsVerifies that all required options are set.
prepareCreates a JetBrains Space Deployment Target if it does not yet exist.
publishStarts a JetBrains Space Deployment.
successMarks the JetBrains Space Deployment as completed.
failMarks the JetBrains Space Deployment as failed.

Install

$ npm install --save-dev semantic-release-space

Usage

The plugin can be configured in the semantic-release configuration file:

"plugins": [
  ...
  [
    "semantic-release-space", {
      "targetId": "example-target"
    }
  ]
  ...
]

With this example a JetBrains Space Deployment will be published on the example-target deployment target .

Configuration

Make sure to set targetId or JB_SPACE_TARGET_ID to the deployment target you want to use. All other options are automatically set via their environment variables in a Space Job.

Options and Environment variables

OptionEnvironment variableTypeDescription
targetJB_SPACE_TARGET_IDTargetConfigurationRequiredThe Space deployment target(s)Set to an key value object to specify target(s) per branch
projectIdJB_SPACE_PROJECT_IDstringRequired Automatically set in JetBrains Space JobsThe Space project id
apiUrlJB_SPACE_API_URLstringRequired Automatically set in JetBrains Space JobsThe Space API url
apiTokenJB_SPACE_TOKENJB_SPACE_CLIENT_TOKENstringRequired Automatically set in JetBrains Space JobsThe Space API auth token
repositoryNameJB_SPACE_GIT_REPOSITORY_NAMEstringRequired Automatically set in JetBrains Space JobsThe repositories name
requireTargetJB_SPACE_REQUIRE_TARGETbooleanDefaults to trueIf set to false an invalid or missing target configuration will be ignored instead of throwing an error
jobJB_SPACE_JOB_IDJobConfigurationDefaults to []The Space automation job(s) to startSet to an key value object to specify job(s) per branch
jobTimeoutJB_SPACE_JOB_TIMEOUTnumberDefaults to 3600The max timeout waiting for jobs to complete in seconds
jobCheckIntervalJB_SPACE_JOB_CHECK_INTERVALnumberDefaults to 10The interval between job status checks in seconds

Option Types

  • TargetConfiguration: string | string[] | { [branch: string]: string | string[] }
  • JobConfiguration: JobBranchConfiguration | { [branch: string]: JobBranchConfiguration }
  • JobBranchConfiguration: string | string[] | { id: string, parameters?: { [name: string]: string } }

Job Parameters

Job parameters can be set via the parameters property of a job configuration for all or only specific branches. The values will be parsed using Handlebars and with the plugin context as template context. Examples:

  • "parameters": { "hello": "world" } will set the parameter hello to world
  • "parameters": { "version": "{{nextRelease.version}}" } will set the parameter version to the next release version
  • "parameters": { "channel": "{{#if nextRelease.channel}}{{nextRelease.channel}}{{else}}latest{{/if}}" } will set the parameter channel to the next release channel or latest if no channel is set

Job Example

With this example the package.json will be pumped and committed, a NPM package will be published and a JetBrains Space Deployment of the new tag will be published on the example-target deployment target.

Authentication

  • Go into your Space Instance > Extensions > Applications and create a new Application (or select an existing one).
  • Go into Authorization and give the Application at least the following permissions for the target project:
    • Read Git repositories
    • Write Git repositories
    • Create package registries
    • Read package registries
    • Write package registires
  • Go into Permanent Tokens and create and copy a new token for the Application.
  • Go into Projects > your target project > Settings > Secrets & Parameters > and create a new secret:
    • key: ci-token
    • value: <application key>:<the token you just coppied>

.releaserc

{
  "branches": [
    "main"
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {}
    ],
    [
      "@semantic-release/release-notes-generator",
      {
        "linkCompare": false,
        "linkReferences": false
      }
    ],
    [
      "semantic-release-space",
      {
        "targetId": "example-target",
        "job": {
          "id": "Example",
          "parameters": {
            "example-param": "example-value",
            "release-version": "{{nextRelease.version}}",
            "release-channel": "{{#if nextRelease.channel}}{{nextRelease.channel}}{{else}}latest{{/if}}"
          }
        }
      }
    ],
    [
      "@semantic-release/npm",
      {}
    ],
    [
      "@semantic-release/git",
      {
        "assets": [
          "package.json"
        ],
        "message": "release: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]
}

.space.kts

job("Release") {
  git {
    refSpec = "refs/heads/main"
  }

  container(displayName = "Publish", image = "node:lts") {
    env["GIT_CREDENTIALS"] = Secrets("ci-token")
    env["NPM_TOKEN"] = Secrets("ci-token")
    shellScript {
      content = """
        npm install
        npx semantic-release
      """
    }
  }
}

job("Example") {
  parameters {       
    text("release-version")
    text("release-channel")
    text("example-param")
  }

  startOn {}

  container(image = "alpine:lts") {
    shellScript {
      content = """
        echo {{ release-version }}
        echo {{ release-channel }}
        echo {{ example-param }}
      """
    }
  }  
}
1.4.1

11 months ago

1.4.0

11 months ago

1.4.0-beta.4

11 months ago

1.4.0-beta.3

11 months ago

1.4.0-beta.2

11 months ago

1.4.0-beta.1

11 months ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago