Skip to content

Jest works

Jest works #340

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/HoneybeeSchema
run: |
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe" -k HoneybeeSchema.snk
ls
shell: cmd
- name: Build
run: |
dotnet restore
dotnet build --configuration Release
- name: Run Unit Tests
working-directory: src/HoneybeeSchema.Tests
run: dotnet test --configuration Release
- name: Release CSharp
working-directory: src/HoneybeeSchema
run: dotnet pack --configuration Release --output ./../../
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nugetPackage
path: ./*.nupkg
buildTypeScript:
name: Build release 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 module
working-directory: src/TypeScriptSDK
run: |
npm run build
npm run bundle:dts
- name: Pack package
working-directory: src/TypeScriptSDK
run: |
npm pack
cp ./*.tgz ./../../
- name: Unit tests
working-directory: src/TypescriptSDK.Tests
run: |
npm i ./../TypeScriptSDK/honeybee-schema-${{env.RELEASE_VERSION}}.tgz
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
updateDownstremRepo:
name: Update dependencies
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: [release, genNewVersion]
env:
RELEASE_VERSION: ${{ needs.genNewVersion.outputs.ReleaseVersion }}
steps:
- name: Wait for NuGet package to be available
shell: bash
run: |
PACKAGE_NAME="honeybeeschema"
PACKAGE_VERSION="${{ env.RELEASE_VERSION }}"
MAX_ATTEMPTS=10
SLEEP_TIME=60
for ((i=1;i<=MAX_ATTEMPTS;i++)); do
RESPONSE=$(curl --silent "https://api.nuget.org/v3-flatcontainer/$PACKAGE_NAME/$PACKAGE_VERSION/$PACKAGE_NAME.nuspec")
if [[ $RESPONSE != *"<Error><Code>BlobNotFound</Code><Message>"* ]]; then
echo "Package ($PACKAGE_NAME/$PACKAGE_VERSION) is available on NuGet."
exit 0
else
echo "Package ($PACKAGE_NAME/$PACKAGE_VERSION) is not available yet. Retry $i/$MAX_ATTEMPTS."
sleep $SLEEP_TIME
fi
done
echo "Package ($PACKAGE_NAME/$PACKAGE_VERSION) is not available after $MAX_ATTEMPTS retries."
exit 1
- name: Update dragonfly-schema-dotnet
env:
DISPATCH_REPO: ladybug-tools/dragonfly-schema-dotnet
DEPS_TOKEN: ${{ secrets.DEPS_UPDATING }}
VERSION: ${{ needs.buildCSharp.outputs.tag }}
run: |
echo ${VERSION}
curl -X POST https://api.github.com/repos/$DISPATCH_REPO/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-d '{"event_type": "honeybee_schema_dotnet_release", "client_payload": {"version": "${{ needs.buildCSharp.outputs.tag }}"}}' \
-u ladybugbot:$DEPS_TOKEN