-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77a4bc6
commit bb46ce2
Showing
17 changed files
with
536 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Bump Homebrew formula for CLI | ||
|
||
on: | ||
# Since now release depends on schedule, might be that there is a situation we cannot wait for schedule and trigger release manually | ||
workflow_dispatch: | ||
# We cannot run brew release continusly every time we release something as sometimes we release a couple of times a day and overload brew pipelines | ||
# schedule: | ||
# - cron: "0 23 * * *" | ||
|
||
jobs: | ||
bump-formula-in-homebrew: | ||
if: github.repository == 'the-codegen-project/cli' | ||
name: Bump the formula in homebrew-core repo | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Get version from package.json | ||
id: extractver | ||
run: echo "version=$(npm run get-version --silent)" >> $GITHUB_OUTPUT | ||
- uses: mislav/bump-homebrew-formula-action@v2 | ||
with: | ||
# A PR will be sent to github.com/Homebrew/homebrew-core to update The Codegen Project formula: | ||
formula-name: the-codegen-project | ||
# https://github.com/mislav/bump-homebrew-formula-action/issues/58 | ||
formula-path: Formula/a/the-codegen-project.rb | ||
tag-name: ${{ steps.extractver.outputs.version }} | ||
download-url: https://registry.npmjs.org/@the-codegen-project/cli/-/cli-${{ steps.extractver.outputs.version }}.tgz #we need to point to npm not github as there is a dist that is not on github | ||
env: | ||
COMMITTER_TOKEN: ${{ secrets.GH_TOKEN_BOT_EVE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string]$version, | ||
[string]$checksum, | ||
[string]$checksum64 | ||
) | ||
|
||
$filePaths = @( | ||
'./tools/chocolateyinstall.ps1' | ||
'./the-codegen-project.nuspec' | ||
) | ||
|
||
foreach ($filePath in $filePaths) { | ||
$fileContents = Get-Content $filePath | ||
$fileContents = $fileContents -replace '{{version}}', $version | ||
$fileContents = $fileContents -replace '{{checksum}}', $checksum | ||
$fileContents = $fileContents -replace '{{checksum64}}', $checksum64 | ||
Set-Content $filePath $fileContents | ||
} |
31 changes: 31 additions & 0 deletions
31
.github/workflows/deploy/chocolatey/the-codegen-project.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<id>the-codegen-project</id> | ||
<version>{{version}}</version> | ||
<packageSourceUrl>https://github.com/the-codegen-project/cli/releases/v{{version}}</packageSourceUrl> | ||
<owners>the-codegen-project</owners> | ||
|
||
<!-- == SOFTWARE SPECIFIC SECTION == --> | ||
<!-- This section is about the software itself --> | ||
<title>the-codegen-project</title> | ||
<authors>the-codegen-project</authors> | ||
<projectUrl>https://www.the-codegen-project.com/</projectUrl> | ||
<iconUrl>https://avatars.githubusercontent.com/u/16401334?s=200</iconUrl> | ||
<copyright>2024 The Codegen Project</copyright> | ||
<licenseUrl>https://github.com/the-codegen-project/cli/blob/master/LICENSE</licenseUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<releaseNotes>https://github.com/the-codegen-project/cli/releases/v{{version}}</releaseNotes> | ||
<projectSourceUrl>https://github.com/the-codegen-project/cli</projectSourceUrl> | ||
<docsUrl>https://www.the-codegen-project.com/</docsUrl> | ||
<bugTrackerUrl>https://github.com/the-codegen-project/cli/issues/new/choose</bugTrackerUrl> | ||
<tags>the-codegen-project cli nodejs api asyncapi codegenerator</tags> | ||
<summary>CLI to generate code</summary> | ||
<description>CLI to generate code</description> | ||
</metadata> | ||
<files> | ||
<!-- this section controls what actually gets packaged into the Chocolatey package --> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
26 changes: 26 additions & 0 deletions
26
.github/workflows/deploy/chocolatey/tools/chocolateyinstall.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$ErrorActionPreference = 'Stop' # stop on all errors | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
|
||
$url = 'https://github.com/the-codegen-project/cli/releases/download/v{{version}}/codegen.x86.exe' | ||
$url64 = 'https://github.com/the-codegen-project/cli/releases/download/v{{version}}/codegen.x64.exe' | ||
|
||
$packageArgs = @{ | ||
packageName = $env:ChocolateyPackageName | ||
unzipLocation = $toolsDir | ||
fileType = 'EXE' | ||
url = $url | ||
url64bit = $url64 | ||
#file = $fileLocation NOTE: Commented out because we are using url instead | ||
|
||
softwareName = 'the-codegen-project*' | ||
|
||
checksum = '{{checksum}}' | ||
checksumType = 'sha256' #default is md5, can also be sha1, sha256 or sha512 | ||
checksum64 = '{{checksum64}}' | ||
checksumType64= 'sha256' #default is checksumType | ||
|
||
validExitCodes= @(0, 3010, 1641) | ||
silentArgs = '/S' # NSIS | ||
} | ||
|
||
Install-ChocolateyPackage @packageArgs # https://docs.chocolatey.org/en-us/create/functions/install-chocolateypackage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Lint PR title | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, reopened, synchronize, edited, ready_for_review] | ||
|
||
jobs: | ||
lint-pr-title: | ||
name: Lint PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ !contains(fromJson('["dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }} | ||
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 #version 5.2.0 https://github.com/amannn/action-semantic-pull-request/releases/tag/v5.2.0 | ||
id: lint_pr_title | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} | ||
with: | ||
subjectPattern: ^(?![A-Z]).+$ | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character. | ||
# Comments the error message from the above lint_pr_title action | ||
- if: ${{ always() && steps.lint_pr_title.outputs.error_message != null && !contains(fromJson('["dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)}} | ||
name: Comment on PR | ||
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 | ||
with: | ||
header: pr-title-lint-error | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} | ||
message: | | ||
We require all PRs to follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). | ||
More details 👇🏼 | ||
``` | ||
${{ steps.lint_pr_title.outputs.error_message}} | ||
``` | ||
# deletes the error comment if the title is correct | ||
- if: ${{ steps.lint_pr_title.outputs.error_message == null }} | ||
name: delete the comment | ||
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 | ||
with: | ||
header: pr-title-lint-error | ||
delete: true | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: PR testing - if Node project | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, ready_for_review] | ||
|
||
jobs: | ||
test-nodejs-pr: | ||
name: Test NodeJS PR - ${{ 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 | ||
shell: bash | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- 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@v4 | ||
with: | ||
node-version: "${{ steps.lockversion.outputs.version }}" | ||
- #npm cli 10 is buggy because of some cache issue | ||
name: Install npm cli 8 | ||
shell: bash | ||
run: npm install -g [email protected] | ||
- name: Install dependencies | ||
shell: bash | ||
run: npm ci | ||
- name: Test | ||
run: npm test --if-present | ||
- if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest' | ||
#linting should run just one and not on all possible operating systems | ||
name: Run linter | ||
run: npm run lint --if-present | ||
- name: Run release assets generation to make sure PR does not break it | ||
shell: bash | ||
run: npm run generate:assets --if-present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Release Chocolatey Package | ||
on: | ||
# We cannot run chocolatey release continusly every time we release something as sometimes we release a couple of times a day and overload chocolatey pipelines | ||
# schedule: | ||
# - cron: '0 23 * * *' # Run every day at 23:00 UTC | ||
# Since now release depends on schedule, might be that there is a situation we cannot wait for schedule and trigger release manually | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to release (optional)' | ||
required: false | ||
|
||
jobs: | ||
release: | ||
name: Publish to Chocolatey Community | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set Version | ||
id: release_version | ||
run: | | ||
if ( "${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ github.event.inputs.version }}" -ne "" ) { | ||
$version = "${{ github.event.inputs.version }}" | ||
} | ||
else { | ||
$version = $(npm pkg get version) | ||
} | ||
$version = $version.Replace("`"", "") | ||
echo "Setting version to $version" | ||
echo "version=$version" >> $env:GITHUB_OUTPUT | ||
- name: Check if this is a new version to release | ||
id: check_new_version | ||
run: | | ||
$output = choco search the-codegen-project --version=${{ steps.release_version.outputs.version }} | ||
# Output is of the form: | ||
# Chocolatey v2.2.2 | ||
# the-codegen-project 0.0.1 [Approved] | ||
# 1 packages found. | ||
# If the version is not found, the output will of the form: | ||
# Chocolatey v2.2.2 | ||
# 0 packages found. | ||
if ($output -match "0 packages found.") { | ||
echo "This is a new version to release" | ||
echo "new_version=true" >> $env:GITHUB_OUTPUT | ||
} | ||
else { | ||
echo "This is not a new version to release" | ||
echo "new_version=false" >> $env:GITHUB_OUTPUT | ||
} | ||
- name: Download release | ||
if: steps.check_new_version.outputs.new_version == 'true' | ||
run: | | ||
echo "Downloading release assets for version ${{ steps.release_version.outputs.version }}" | ||
mkdir -p ./dist/win32 | ||
curl -L "https://github.com/the-codegen-project/cli/releases/download/v${{ steps.release_version.outputs.version }}/codegen.x64.exe" -o "./dist/win32/codegen.x64.exe" | ||
curl -L "https://github.com/the-codegen-project/cli/releases/download/v${{ steps.release_version.outputs.version }}/codegen.x86.exe" -o "./dist/win32/codegen.x86.exe" | ||
- name: Get Checksum of the release | ||
if: steps.check_new_version.outputs.new_version == 'true' | ||
id: release_checksum | ||
run: | | ||
$checksum = (Get-FileHash -Path "./dist/win32/codegen.x86.exe" -Algorithm SHA256).Hash | ||
$checksum64 = (Get-FileHash -Path "./dist/win32/codegen.x64.exe" -Algorithm SHA256).Hash | ||
echo "Setting checksum to $checksum" | ||
echo "checksum=$checksum" >> $env:GITHUB_OUTPUT | ||
echo "Setting checksum64 to $checksum64" | ||
echo "checksum64=$checksum64" >> $env:GITHUB_OUTPUT | ||
- name: Make nuspec from the template | ||
if: steps.check_new_version.outputs.new_version == 'true' | ||
run: | | ||
cd ./.github/workflows/deploy/chocolatey | ||
pwsh -File ./replace.ps1 -version ${{ steps.release_version.outputs.version }} -checksum ${{ steps.release_checksum.outputs.checksum }} -checksum64 ${{ steps.release_checksum.outputs.checksum64 }} | ||
- name: Run Chocolatey Pack | ||
if: steps.check_new_version.outputs.new_version == 'true' | ||
run: | | ||
cd ./.github/workflows/deploy/chocolatey | ||
choco pack ./the-codegen-project.nuspec | ||
choco apikey add --source "'https://push.chocolatey.org/'" --key ${{ secrets.CHOCOLATEY_API_KEY }} | ||
choco push ./the-codegen-project.${{ steps.release_version.outputs.version }}.nupkg --source "'https://push.chocolatey.org/'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- next | ||
|
||
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, 'the-codegen-project/' ) && | ||
(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 | ||
shell: bash | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- 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@v4 | ||
with: | ||
node-version: "${{ steps.lockversion.outputs.version }}" | ||
- 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 | ||
run: npm install -g [email protected] | ||
- name: Install dependencies | ||
shell: bash | ||
run: npm ci | ||
- name: Run test | ||
run: npm test --if-present | ||
|
||
release: | ||
needs: [test-nodejs] | ||
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 | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global core.eol lf | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- 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@v4 | ||
with: | ||
node-version: "${{ steps.lockversion.outputs.version }}" | ||
- name: Install dependencies | ||
shell: bash | ||
run: npm ci | ||
- name: Add plugin for conventional commits for semantic-release | ||
run: npm install --save-dev [email protected] | ||
- name: Publish to any of NPM, Github, and Docker Hub | ||
id: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
GIT_AUTHOR_NAME: jonaslagoni | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: jonaslagoni | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
run: npx [email protected] |
Oops, something went wrong.