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: /.gitlab/publishing.gitlab-ci.yml
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_TAG
when: always
variables:
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:
stage: publish
needs: ['build']
needs: ['build', 'test', 'integration', 'e2e']
script:
- pnpm install
- pnpm run deploy
@@ -8,9 +8,7 @@ deploy:
paths:
- ./.deploy
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
- if: $CI_COMMIT_TAG
- when: on_success
publish images:
stage: publish
@@ -25,14 +23,9 @@ publish images:
- /kaniko/executor
--context "${CI_PROJECT_DIR}/${DEPLOY_DIR}"
--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:
- if: $CI_COMMIT_TAG
variables:
DOCKER_TAG: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
DOCKER_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- when: on_success
parallel:
matrix:
- DEPLOY_DIR: backend/database
@@ -42,20 +35,17 @@ publish images:
- DEPLOY_DIR: .deploy/proxy
IMAGE_NAME: proxy
publish:
publish packages:
stage: publish
needs: ['deploy']
script:
- pnpm install --prefer-offline
- pnpm install
- pnpm build
- pnpm changeset version $PUBLISH_TYPE
- pnpm changeset publish
- pnpm publish -r
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
PUBLISH_TYPE: --snapshot $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- when: on_success
pages:docs:
publish docs:
stage: publish
needs: ['deploy']
script:
@@ -66,5 +56,4 @@ pages:docs:
paths:
- public
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: on_success

View File

@@ -33,6 +33,13 @@ const config = {
'nyc',
],
versionGroups: [
{
label: 'Package version is controlled by changesets',
dependencies: ['**'],
dependencyTypes: ['workspace'],
packages: ['**'],
isIgnored: true,
},
{
label: 'ES Mapping Generator Special Dependencies',
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`
```shell
pnpm publish-packages
```
Internally, this will run
```shell
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 build # make sure all packages are built
pnpm publish -r # publish all packages not yet in the registry
git add .
git commit -m "v[VERSION]"
git tag -a "v[VERSION]"
git commit -m "refactor: update changelog"
pnpm changeset tags
git push --follow-tags
# from here the pipeline will do the publishing
```
## Remote caching

View File

@@ -32,7 +32,7 @@
"build:docker": "docker build -t openstapps:backend ../../.deploy/backend",
"deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend",
"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:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "tsc --noEmit && eslint --ext .ts src/",

View File

@@ -17,7 +17,8 @@
"format:fix": "dotenv -c -- turbo run format:fix",
"lint": "dotenv -c -- turbo run lint",
"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",
"test": "trap 'node coverage.mjs' EXIT && dotenv -c -- turbo run test --filter=!@openstapps/app",
"test:integration": "dotenv -c -- turbo run test:integration",