feat: publishing workflow

This commit is contained in:
2023-06-30 13:38:28 +02:00
parent 2d061b1638
commit 995cc89d17
8 changed files with 41 additions and 29 deletions

View File

@@ -0,0 +1,5 @@
---
'@openstapps/projectmanagement': patch
---
Update release configs

View File

@@ -12,8 +12,8 @@ include:
- local: /frontend/app/.gitlab-ci.yml - local: /frontend/app/.gitlab-ci.yml
- local: /.gitlab/publishing.gitlab-ci.yml - local: /.gitlab/publishing.gitlab-ci.yml
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_TAG
when: never when: always
variables: variables:
TURBO_CACHE_BYPASS: TURBO_CACHE_BYPASS:

3
.gitlab/ci/getVersion.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
grep -oP '(?<="version": ")[^"]*' "$1"

View File

@@ -1,6 +1,6 @@
deploy: deploy:
stage: publish stage: publish
needs: ['build'] needs: ['build', 'test', 'integration', 'e2e']
script: script:
- pnpm install - pnpm install
- pnpm run deploy - pnpm run deploy
@@ -8,9 +8,7 @@ deploy:
paths: paths:
- ./.deploy - ./.deploy
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - when: on_success
when: manual
- if: $CI_COMMIT_TAG
publish images: publish images:
stage: publish stage: publish
@@ -25,14 +23,9 @@ publish images:
- /kaniko/executor - /kaniko/executor
--context "${CI_PROJECT_DIR}/${DEPLOY_DIR}" --context "${CI_PROJECT_DIR}/${DEPLOY_DIR}"
--dockerfile "${CI_PROJECT_DIR}/${DEPLOY_DIR}/Dockerfile" --dockerfile "${CI_PROJECT_DIR}/${DEPLOY_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${DOCKER_TAG}" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(./.gitlab/ci/getVersion.sh ${DEPLOY_DIR}/package.json)
rules: rules:
- if: $CI_COMMIT_TAG - when: on_success
variables:
DOCKER_TAG: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
DOCKER_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
parallel: parallel:
matrix: matrix:
- DEPLOY_DIR: backend/database - DEPLOY_DIR: backend/database
@@ -42,20 +35,17 @@ publish images:
- DEPLOY_DIR: .deploy/proxy - DEPLOY_DIR: .deploy/proxy
IMAGE_NAME: proxy IMAGE_NAME: proxy
publish: publish packages:
stage: publish stage: publish
needs: ['deploy'] needs: ['deploy']
script: script:
- pnpm install --prefer-offline - pnpm install
- pnpm build - pnpm build
- pnpm changeset version $PUBLISH_TYPE - pnpm publish -r
- pnpm changeset publish
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - when: on_success
variables:
PUBLISH_TYPE: --snapshot $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
pages:docs: publish docs:
stage: publish stage: publish
needs: ['deploy'] needs: ['deploy']
script: script:
@@ -66,5 +56,4 @@ pages:docs:
paths: paths:
- public - public
rules: rules:
- if: $CI_COMMIT_TAG - when: on_success
when: on_success

View File

@@ -33,6 +33,13 @@ const config = {
'nyc', 'nyc',
], ],
versionGroups: [ versionGroups: [
{
label: 'Package version is controlled by changesets',
dependencies: ['**'],
dependencyTypes: ['workspace'],
packages: ['**'],
isIgnored: true,
},
{ {
label: 'ES Mapping Generator Special Dependencies', label: 'ES Mapping Generator Special Dependencies',
dependencies: ['typescript', 'typedoc', 'ts-node', '@types/node', 'got'], dependencies: ['typescript', 'typedoc', 'ts-node', '@types/node', 'got'],

View File

@@ -27,15 +27,22 @@ Refer to the [contribution guide](./CONTRIBUTING.md)
After having added all changes using `pnpm changeset` After having added all changes using `pnpm changeset`
```shell
pnpm publish-packages
```
Internally, this will run
```shell ```shell
pnpm changeset version # bump versions pnpm changeset version # bump versions
pnpm syncpack:fix
pnpm format:fix # changes to the package.json can cause issues
pnpm install # update lockfile and rebuild packages pnpm install # update lockfile and rebuild packages
pnpm build # make sure all packages are built
pnpm publish -r # publish all packages not yet in the registry
git add . git add .
git commit -m "v[VERSION]" git commit -m "refactor: update changelog"
git tag -a "v[VERSION]" pnpm changeset tags
git push --follow-tags git push --follow-tags
# from here the pipeline will do the publishing
``` ```
## Remote caching ## Remote caching

View File

@@ -32,7 +32,7 @@
"build:docker": "docker build -t openstapps:backend ../../.deploy/backend", "build:docker": "docker build -t openstapps:backend ../../.deploy/backend",
"deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend", "deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend",
"dev": "tsup --watch --onSuccess \"pnpm run start\"", "dev": "tsup --watch --onSuccess \"pnpm run start\"",
"docs": "openapi build-docs ./node_modules/@openstapps/core/lib/openapi.json -o docs/openapi/index.html", "docs:disabled": "openapi build-docs --file ./node_modules/@openstapps/core/lib/openapi.json --output-dir docs/openapi",
"format": "prettier . -c --ignore-path ../../.gitignore", "format": "prettier . -c --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore", "format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "tsc --noEmit && eslint --ext .ts src/", "lint": "tsc --noEmit && eslint --ext .ts src/",

View File

@@ -17,7 +17,8 @@
"format:fix": "dotenv -c -- turbo run format:fix", "format:fix": "dotenv -c -- turbo run format:fix",
"lint": "dotenv -c -- turbo run lint", "lint": "dotenv -c -- turbo run lint",
"lint:fix": "dotenv -c -- turbo run lint:fix", "lint:fix": "dotenv -c -- turbo run lint:fix",
"syncpack": "syncpack list-mismatches && syncpack lint-semver-ranges", "publish-packages": "pnpm changeset version && pnpm syncpack:fix && pnpm install && git add . && git commit -m \"refactor: update changelog\" && pnpm changeset tags && git push --follow-tags",
"syncpack": "syncpack list-mismatches && syncpack lint-semver-ranges --types dev,peer,prod",
"syncpack:fix": "syncpack format && syncpack fix-mismatches", "syncpack:fix": "syncpack format && syncpack fix-mismatches",
"test": "trap 'node coverage.mjs' EXIT && dotenv -c -- turbo run test --filter=!@openstapps/app", "test": "trap 'node coverage.mjs' EXIT && dotenv -c -- turbo run test --filter=!@openstapps/app",
"test:integration": "dotenv -c -- turbo run test:integration", "test:integration": "dotenv -c -- turbo run test:integration",