Skip to content

Commit

Permalink
feat: include default nunjucks filters and new release to the generat…
Browse files Browse the repository at this point in the history
…or (#1225)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>%0ACo-authored-by: HUTCHHUTCHHUTCH <55915170+HUTCHHUTCHHUTCH@users.noreply.github.com>%0ACo-authored-by: asyncapi-bot <61865014+asyncapi-bot@users.noreply.github.com>%0ACo-authored-by: Amrut Prabhu <amrutprabhu42@gmail.com>%0ACo-authored-by: asyncapi-bot <bot+chan@asyncapi.io>%0ACo-authored-by: Christeen Fernando <christeenfdo24@gmail.com>%0ACo-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>%0ACo-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
  • Loading branch information
ayushnau and magicmatatjahu authored Jul 29, 2024
1 parent bc9dbec commit 99a14a8
Show file tree
Hide file tree
Showing 31 changed files with 10,287 additions and 6,487 deletions.
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/config@2.3.0/schema.json",
"changelog": ["@changesets/changelog-git", { "repo": "asyncapi/generator" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"ignore": ["@asyncapi/nunjucks-filters"],
"updateInternalDependencies": "patch",
"privatePackages": {
"version": true,
"tag": true
}
}
7 changes: 7 additions & 0 deletions .changeset/wise-laws-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@asyncapi/generator": minor
---

- New release pipeline supporting monorepo,
- Package `@asyncapi/generator-filters` is now part of `generator` repo and won't be released separately. New name of the library is `nunjuckis-filters`,
- By default `@asyncapi/generator-filters` package, known as package with a lot of different nunjucks filters, is registered and added to generator and you no longer have to configure it in your `package.json`. Package `@asyncapi/generator-filters` will no longer be published to NPM separately and is deprecated.
15 changes: 3 additions & 12 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# This action is centrally managed in https://github.com/asyncapi/.github/
# 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

# Purpose of this action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only.
# It runs in a repo after merge of release commit and searches for other packages that use released package. Every found package gets updated with lates version

name: Bump package version in dependent repos - if Node project
name: Bump package version in dependent repos

on:
# It cannot run on release event as when release is created then version is not yet bumped in package.json
Expand All @@ -21,15 +15,12 @@ jobs:
steps:
- name: Checkout repo
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
- if: steps.packagejson.outputs.exists == 'true'
name: Bumping latest version of this package in other repositories
- name: Bumping latest version of this package in other repositories
uses: derberg/npm-dependency-manager-for-your-github-org@1eafd3bf3974f21d395c1abac855cb04b295d570 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6
with:
github_token: ${{ secrets.GH_TOKEN }}
committer_username: asyncapi-bot
committer_email: info@asyncapi.io
repos_to_ignore: spec,bindings,saunter,server-api
packagejson_path: ./apps/generator
custom_id: "dependency update from asyncapi bot"
69 changes: 0 additions & 69 deletions .github/workflows/if-nodejs-version-bump.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/local-generate-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# this workflow runs after releases to generate some files like for example api.md
name: Autogenerate API files

on:
release:
types:
- published

jobs:
version_bump:
name: Generate assets and bump NodeJS
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases
# in case release is created from release branch then we need to checkout from given branch
# if @semantic-release/github is used to publish, the minimum version is 7.2.0 for proper working
ref: ${{ github.event.release.target_commitish }}
- name: Check package-lock version
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
id: lockversion
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.lockversion.outputs.version }}"
- name: Install dependencies
run: npm ci
- name: Assets generation
run: npm run generate:assets --if-present
- name: Create Pull Request with updated asset files including package.json
uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: 'chore(release): ${{github.event.release.tag_name}}'
committer: asyncapi-bot <info@asyncapi.io>
author: asyncapi-bot <info@asyncapi.io>
title: 'chore: update assets'
body: 'Updating assets like for example API.md, but not only, that shoudl be generated and not manually updated'
branch: assets-update/${{github.event.release.tag_name}}
- 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: 'Unable to bump the version in package.json after the release'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
1 change: 1 addition & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- name: Build Image
uses: docker/build-push-action@v4
with:
context: './apps/generator'
push: true
load: false
build-args: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# This action is centrally managed in https://github.com/asyncapi/.github/
# 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
# It does magic only if there is a package.json file in the root of the project
name: Release

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
# The below lines are not enough to have release supported for these branches
- next-spec
- next-major
- next-major-spec
Expand All @@ -19,14 +15,15 @@ on:

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"
# We just check the message of the first commit as there is always just one commit because we squash into one before merging
# "commits" contains an array of objects where one of the properties is the 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, 'chore(release):' ) ||
startsWith( github.event.commits[0].message, 'feat!:' ))
name: Test NodeJS release on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -36,7 +33,7 @@ jobs:
# See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
- name: Set git to use LF # To once and for all finish the never-ending fight between Unix and Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
Expand All @@ -59,7 +56,7 @@ jobs:
- if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest'
name: Install npm cli 8
shell: bash
#npm cli 10 is buggy because of some cache issues
# npm cli 10 is buggy because of some cache issues
run: npm install -g npm@8.19.4
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
Expand All @@ -80,10 +77,10 @@ jobs:

release:
needs: [test-nodejs]
name: Publish to any of NPM, Github, or Docker Hub
name: Publish to any of NPM, GitHub, or Docker Hub
runs-on: ubuntu-latest
steps:
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
- name: Set git to use LF # To once and for all finish the never-ending fight between Unix and Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
Expand All @@ -107,22 +104,29 @@ jobs:
shell: bash
run: npm ci
- if: steps.packagejson.outputs.exists == 'true'
name: Add plugin for conventional commits for semantic-release
run: npm install --save-dev conventional-changelog-conventionalcommits@5.0.0
name: Install changelog
shell: bash
# This step can be removed once the issue is fixed in the changeset package.
run: npm install @changesets/changelog-git@0.2.0
- if: steps.packagejson.outputs.exists == 'true'
name: Publish to any of NPM, Github, and Docker Hub
#this step has 2 goals, it is either identifying that there is changeset file created and then this action creates a PR with version bump that will trigger release - or if it sees there is no changeset, and there are versions changes in package.json files, it publish new versions to NPM is they are not there yet
uses: changesets/action@v1
id: release
with:
version: npx -p @changesets/cli@2.27.7 changeset version
commit: "chore(release): release and bump versions of packages"
title: "chore(release): release and bump versions of packages"
publish: npx -p @changesets/cli@2.27.7 changeset publish
setupGitUser: false
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: info@asyncapi.io
GIT_COMMITTER_NAME: asyncapi-bot
GIT_COMMITTER_EMAIL: info@asyncapi.io
run: npx semantic-release@19.0.4
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
- 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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

node_modules
**/node_modules/

# Local env files
.env
Expand Down
Loading

0 comments on commit 99a14a8

Please sign in to comment.