Skip to content
Snippets Groups Projects
Commit 20180d27 authored by GridexX's avatar GridexX :art: Committed by Thomas Boni
Browse files

feat: new job vscode_publish


Signed-off-by: default avatarGridexX <arsene582@gmail.com>
parent 7b89c1cf
No related branches found
No related tags found
1 merge request!460Resolve "[New job] - vscode_publish"
# Changelog
All notable changes to this job will be documented in this file.
## [0.1.0] - 2023-04-12
* Initial version
## Objective
Deploy your extension on the [Visual Studio Marketplace](https://marketplace.visualstudio.com/) with [VSCE](https://www.npmjs.com/package/@vscode/vsce). This job package your extension and publish it on the marketplace.
## How to use it
1. Copy the job URL located in the `Install` part of the right panel and add it inside the `include` list of your `.gitlab-ci.yml` file (see the [quick use](https://docs.r2devops.io/get-started/use-templates/#use-a-template)). You can specify [a fixed version](https://docs.r2devops.io/get-started/use-templates/#versioning) instead of `latest`.
2. Set credentials variable `VSCE_PAT` in
the GitLab CI/CD variables section of your project. Follow the [documentation](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) for retrieving it.
3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization)
4. Well done, your job is ready to work ! 😀
## Variables
| Name | Description | Default |
| ---- | ----------- | ------- |
| `RELEASE_VERSION` <img width=100/> | The release version of the extension to publish. <img width=175/>| `${RELEASE_VERSION}` <img width=100/>|
| `VSCE_PAT`| ⚠️ Mandatory variable. Your [Personal Access Token](https://code.visualstudio.com/api/working-with-extensions/continuous-integration#automated-publishing). This variable should be specified in `GitLab > CI/CD Settings` as variable. | ` ` |
| `VSCE_VERSION` | Version of the [vsce](https://www.npmjs.com/package/@vscode/vsce) package to use. | `2.19.0` |
| `VSCE_ADDITIONAL_OPTIONS` | Additional options for `vsce publish` | ` ` |
| `IMAGE_TAG` | The default tag for the docker image | `18-alpine` |
!!! note "Build Artifact"
This job use the `main` entry define in the `package.json` file to find the build extension's path to package. If you use the [npm_build](https://r2devops.io/marketplace/gitlab/r2devops/hub/npm_build) job to build your extension, you should override the `NPM_BUILD_OUTPUT_FOLDER` variable to specify the path corresponding to the `main` entry.
!!! info "Semantic Release"
This job is compatible with [semantic_release](https://r2devops.io/marketplace/gitlab/r2devops/hub/semantic_release) and use the `RELEASE_VERSION` variable to publish the extension. If you don't use semantic_release, you can specify the version of the extension to publish with the `RELEASE_VERSION` variable.
## Artifacts
This job will expose the `vsix` file generated by `vsce package`. It is exposed as `vscode package`.
## Author
This resource is an **[official job](https://docs.r2devops.io/get-started/faq/#use-a-template)** added in [**R2Devops repository**](https://gitlab.com/r2devops/hub) by [@GridexX](https://gitlab.com/GridexX)
# Job from R2Devops hub --> r2devops.io
stages:
- deploy
vscode_publish:
image:
name: node:${IMAGE_TAG}
stage: deploy
variables:
RELEASE_VERSION: "${RELEASE_VERSION}"
VSCE_PAT: ""
VSCE_OUTPUT_FOLDER: "package"
VSCE_VERSION: "2.19.0"
VSCE_ADDITIONAL_OPTIONS: ""
IMAGE_TAG: "18-alpine"
script:
- npm install -g @vscode/vsce@${VSCE_VERSION}
- cd $CI_PROJECT_DIR
- mkdir -p ${VSCE_OUTPUT_FOLDER}
- if [ ! -z ${RELEASE_VERSION} ]; then
- echo "Release version is set to ${RELEASE_VERSION}"
# Write the new version to the package.json
- npm version ${RELEASE_VERSION} --no-git-tag-version
# Echo the version to the console and remove whitespace
- |
echo "New version added : $(cat package.json | grep version | tr -d ' ' | cut -d: -f2 | tr -d '",')"
- fi
- vsce package -o ${VSCE_OUTPUT_FOLDER}
- vsce publish --packagePath ${VSCE_OUTPUT_FOLDER}/*.vsix ${VSCE_ADDITIONAL_OPTIONS}
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
artifacts:
when: always
expose_as: "vscode package"
paths:
- "${CI_PROJECT_DIR}/${VSCE_OUTPUT_FOLDER}"
files:
template: ./jobs/vscode_publish/vscode_publish.yml
documentation: ./jobs/vscode_publish/README.md
changelog: ./jobs/vscode_publish/CHANGELOG.md
data:
description: Ready to use job that publishes VSCode extension to marketplace
public: true
license: MIT
icon: 🚀
labels:
- Utilities
- Deploy
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment