Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use changesets to manage release #706

Merged
merged 35 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
75141e5
use changesets
KhudaDad414 Jul 4, 2023
f851c53
add ADR
KhudaDad414 Jul 4, 2023
ffcf603
restore line
KhudaDad414 Jul 4, 2023
0fec23d
regenerate package-json
KhudaDad414 Jul 4, 2023
7ff109c
add linux-support
KhudaDad414 Jul 4, 2023
ae0ac8d
Version Packages (#14)
KhudaDad414 Jul 4, 2023
b3ec359
use original publish workflow
KhudaDad414 Jul 4, 2023
ee43893
remove check
KhudaDad414 Jul 4, 2023
fa35c6f
version packages (#15)
KhudaDad414 Jul 4, 2023
5a33a20
remove tests
KhudaDad414 Jul 4, 2023
9c7e1f3
remove extra line
KhudaDad414 Jul 4, 2023
33fb4e6
reset version
KhudaDad414 Jul 4, 2023
6c5c6d0
add docker publish
KhudaDad414 Jul 4, 2023
31dc032
remove semantic release
KhudaDad414 Jul 4, 2023
1af2fe5
regenerate package-lock
KhudaDad414 Jul 4, 2023
12f93d9
version packages (#16)
KhudaDad414 Jul 4, 2023
8501eb9
remove empty env
KhudaDad414 Jul 4, 2023
11147a5
version packages (#17)
KhudaDad414 Jul 4, 2023
5304e4b
testing
KhudaDad414 Jul 4, 2023
61e65f2
version packages (#18)
KhudaDad414 Jul 4, 2023
5435cb6
add correct tag
KhudaDad414 Jul 4, 2023
79894f3
version packages (#19)
KhudaDad414 Jul 4, 2023
a9ed0d9
final touches
KhudaDad414 Jul 4, 2023
71c35cd
regenerate package-lock
KhudaDad414 Jul 4, 2023
c4745c4
Merge remote-tracking branch 'upstream/master'
KhudaDad414 Jul 4, 2023
9a6fa2f
regenerate package-lock
KhudaDad414 Jul 4, 2023
85e1c02
Trigger Build
KhudaDad414 Jul 4, 2023
d9168b4
remove ADR
KhudaDad414 Jul 5, 2023
f5ef498
Create pitch.yml
KhudaDad414 Jul 5, 2023
b50bfc5
Merge branch 'upstream-master'
KhudaDad414 Jul 6, 2023
53dcb10
regenerate package-lock
KhudaDad414 Jul 6, 2023
89b2c30
use correct package name
KhudaDad414 Jul 6, 2023
00f0893
rectify package
KhudaDad414 Jul 6, 2023
c923b1c
Merge branch 'master' into master
KhudaDad414 Jul 6, 2023
5774a70
Merge branch 'master' into master
KhudaDad414 Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["design-system"],
"privatePackages": {
"version": true,
"tag": true
}
}
86 changes: 13 additions & 73 deletions .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,18 @@
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

# It does magic only if there is package.json file in the root of the project
name: Release - if Node project
name: Release
KhudaDad414 marked this conversation as resolved.
Show resolved Hide resolved

on:
push:
branches:
- master
# below lines are not enough to have release supported for these branches
# make sure configuration of `semantic-release` package mentions these branches
- next-spec
- next-major
- next-major-spec
- beta
- alpha

jobs:
test-nodejs:
# We just check the message of first commit as there is always just one commit because we squash into one before merging
# "commits" contains array of objects where one of the properties is commit "message"
# Release workflow will be skipped if release conventional commits are not used
if: |
startsWith( github.repository, 'asyncapi/' ) &&
(startsWith( github.event.commits[0].message , 'fix:' ) ||
startsWith( github.event.commits[0].message, 'fix!:' ) ||
startsWith( github.event.commits[0].message, 'feat:' ) ||
startsWith( github.event.commits[0].message, 'feat!:' ))
name: Test NodeJS release on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v3
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
shell: bash
- if: steps.packagejson.outputs.exists == 'true'
name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
run: npm install
- if: steps.packagejson.outputs.exists == 'true'
name: Run test
run: npm test --if-present
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
name: Report workflow run status to Slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,action,workflow
text: 'Release workflow failed in testing job'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
needs: [test-nodejs]
name: Publish to any of NPM, Github, or Docker Hub
name: Version or Create a Release in Github
runs-on: ubuntu-latest
steps:
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
Expand All @@ -79,32 +24,27 @@ jobs:
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
- if: steps.packagejson.outputs.exists == 'true'
name: Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
- name: Install dependencies
run: npm install
- if: steps.packagejson.outputs.exists == 'true'
name: Publish to any of NPM, Github, and Docker Hub
id: release
- name: Create Release Pull Request or Release
uses: changesets/action@v1
with:
publish: npm run publish
version: npm run version-packages
commit: "version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GIT_AUTHOR_NAME: asyncapi-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: asyncapi-bot
GIT_COMMITTER_EMAIL: [email protected]
run: npm run release
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
name: Report workflow run status to Slack
uses: 8398a7/action-slack@v3
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Create and publish studio Docker image

on:
release:
types: published

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./apps/studio/Dockerfile
push: true
tags: asyncapi/studio:latest
26 changes: 2 additions & 24 deletions apps/design-system/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "design-system",
"version": "1.0.0",
"version": "0.0.0",
"private": true,
"dependencies": {
"@headlessui/react": "^1.7.13",
Expand All @@ -18,12 +18,10 @@
"scripts": {
"lint": "echo \"No linter configured yet\"",
"generate:assets": "echo \"No assets to configure\"",
"bump:version": "../../bump-version.sh design-system",
"test": "echo \"No tests\"",
"eject": "react-scripts eject",
"dev": "storybook dev -p 6006 --no-open",
"build": "storybook build",
"release": "semantic-release -e semantic-release-monorepo"
"build": "storybook build"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -74,25 +72,5 @@
},
"publishConfig": {
"access": "public"
},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/github"
]
}
}
2 changes: 1 addition & 1 deletion apps/studio/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WORKDIR /app
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
RUN npm ci
RUN PUPPETEER_SKIP_DOWNLOAD=true npm ci

# Build the project
COPY --from=builder /app/out/full/ .
Expand Down
33 changes: 2 additions & 31 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@asyncapi/studio",
"version": "1.0.0",
"version": "0.18.0",
"private": true,
"description": "One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.",
"license": "Apache-2.0",
"bugs": {
Expand Down Expand Up @@ -57,9 +58,6 @@
"generate:readme:toc": "markdown-toc -i README.md",
"generate:assets": "npm run build && npm run generate:readme:toc",
"generate:template-parameters": "ts-node ./scripts/template-parameters.ts",
"generate:docker": "docker build -f Dockerfile --tag asyncapi/studio ../../",
"bump:version": "../../bump-version.sh @asyncapi/studio",
"release": "npm run generate:docker && semantic-release -e semantic-release-monorepo",
"prepublishOnly": "npm run build && npm run generate:readme:toc"
},
"browserslist": {
Expand Down Expand Up @@ -136,32 +134,5 @@
},
"publishConfig": {
"access": "public"
},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/github",
[
"@semantic-release-plus/docker",
{
"name": "asyncapi/studio",
"publishChannelTag": true
}
]
]
}
}
41 changes: 41 additions & 0 deletions doc/adr/0002-use-changesets-for-publishing-and-versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 2: Use Changesets for Publishing Packages in the Monorepo
KhudaDad414 marked this conversation as resolved.
Show resolved Hide resolved

Date: 2023-07-04

## Status

Accepted

## Context

The studio repository is a monorepo, and the current use of semantic-release for publishing packages within it is no longer suitable. The following reasons highlight the need for a change:

- **Semantic-release lacks native monorepo support**: Although there have been discussions in the semantic-release community about supporting monorepos, no progress has been made in implementing this feature. While plugins like [semantic-release-monorepo](https://github.com/pmowrer/semantic-release-monorepo) exist, they do not adequately address the management of internal packages.

- **Semantic-release enforces semantic-commits**: Without including the change type in the pull request (PR) title, semantic-release cannot effectively operate.

## Decision

To address the issues outlined above, we will adopt the use of [changesets](https://github.com/changesets/changesets) to manage package releases and publishing to GitHub. Additionally, we will introduce a separate GitHub workflow to handle the release process for different channels.

We choose [changesets](https://github.com/changesets/changesets) for the following reasons:

- **Recommended by Turborepo**: Changesets come highly recommended within the development community, particularly within the context of monorepos.

- **Ease of use**: Changesets provide a user-friendly interface for managing versioning and releases.

- **Support for monorepo and internal packages**: Changesets natively support monorepos and allow for the management of internal packages.

- **Separation of the publishing process**: Changesets allow us to decouple the process of releasing packages from the act of publishing them to platforms like docker.io and other locations.

- **Auto versioning**: Changesets versioning by itself so we can drop the workflow that is responsible for versoning packages after release.

## Consequences

As a result of this change, the following consequences should be considered:

- **Move away from Conventional Commits**: The requirement to adhere to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for PRs will be lifted. Instead, contributors and maintainers must specify their changes using [changesets](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

- **Integration of changesets bot**: To ensure consistent usage of changesets, the [changesets bot](https://github.com/apps/changeset-bot) will be added to the project. This bot will verify the presence of changesets within the repository.

- **disable version bumping workflow**: we can disable the [verson bump workflow](https://github.com/asyncapi/studio/blob/master/.github/workflows/if-nodejs-version-bump.yml) since changesets handles it by itself.
Loading