Skip to content

chore(CI): fix TS tests and release #226

chore(CI): fix TS tests and release

chore(CI): fix TS tests and release #226

Workflow file for this run

name: CD
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
genNewVersion:
name: Check and get a new version for release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get Version
run: |
cd ./.generator/SchemaGenerator
MSG=$(dotnet run --updateVersion | grep "New version")
VERSION=$(echo $MSG | awk -F': ' '{print $2}')
echo "ReleaseVersion $VERSION"
echo "ReleaseVersion=$VERSION" >> $GITHUB_ENV
outputs:
ReleaseVersion: ${{ env.ReleaseVersion }}
buildCSharp:
name: Build release CSharp
runs-on: windows-latest
needs: [genNewVersion]
env:
RELEASE_VERSION: ${{ needs.genNewVersion.outputs.ReleaseVersion }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Generate files
shell: bash
run: |
cd ./.generator/SchemaGenerator
dotnet run --genCsModel --genCsInterface --updateVersion
- name: Create key pair for signing the assembly
if: github.ref == 'refs/heads/master'
working-directory: src/DragonflySchema
run: |
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe" -k LadybugTools.snk
ls
shell: cmd
- name: Build
run: |
dotnet restore
dotnet build --configuration Release
- name: Run Unit Tests
working-directory: src/DragonflySchema.Tests
run: dotnet test --configuration Release
- name: Release CSharp
working-directory: src/DragonflySchema
run: dotnet pack --configuration Release --output ./../../
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nugetPackage
path: ./*.nupkg
buildTypeScript:
name: Build TypeScript
runs-on: ubuntu-latest
needs: [genNewVersion]
env:
CI: ""
RELEASE_VERSION: ${{ needs.genNewVersion.outputs.ReleaseVersion }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: generate files
run: |
cd ./.generator/SchemaGenerator
dotnet run --genTsModel --updateVersion
- name: Install dependencies
working-directory: src/TypeScriptSDK
run: npm i
# - name: Build and bundle module
# working-directory: src/TypeScriptSDK
# run: |
# npm run build
# npm run bundle:dts
- name: Build and pack package
working-directory: src/TypeScriptSDK
run: |
npm pack
cp ./*.tgz ./../../
- name: Unit tests
working-directory: src/TypescriptSDK.Tests
run: |
npm i ./../TypeScriptSDK/dragonfly-schema-${{env.RELEASE_VERSION}}.tgz
npm i honeybee-schema
npm run test
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: npmPackage
path: ./*.tgz
release:
name: Release both CSharp and TypeScript SDK
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: [buildCSharp, buildTypeScript]
steps:
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Download artifact - nuget
uses: actions/download-artifact@v4
with:
name: nugetPackage
- name: Download artifact - npm
uses: actions/download-artifact@v4
with:
name: npmPackage
- name: Release CSharp
run: dotnet nuget push ./*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish ./*.tgz --access public