diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9a874b5 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 005ecca..c1541d4 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,55 +1,268 @@ -name: build-image +#name: build-image +#on: +# push: +# branches: [main] +# +#jobs: +# build-image: +# runs-on: [ubuntu-latest] +# env: +# DOTNET_INSTALL_DIR: "/home/runner" +# permissions: +# contents: write +# packages: write +# steps: +# - name: 'Cleanup build folder' +# run: | +# rm ./* -r || true +# rm ./.??* -r || true +# +# - uses: actions/setup-dotnet@v3 +# with: +# dotnet-version: 8.0.x +# +# - name: Set up GitVersion +# uses: gittools/actions/gitversion/setup@v0.9.15 +# with: +# versionSpec: '5.x' +# +# - name: Checkout code +# uses: actions/checkout@v3 +# with: +# fetch-depth: 0 +# +# - name: Execute GitVersion +# uses: gittools/actions/gitversion/execute@v0.9.15 +# with: +# useConfigFile: true +# configFilePath: GitVersion.yml +# +# - name: login into registry +# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u $ --password-stdin +# +# - name: Build image +# env: +# dockerfile: ./src/comissions.app.api/Dockerfile +# docker_image_name: ghcr.io/comissions-app/core-api +# run: | +# docker build --build-arg NUGET_SOURCE=https://nuget.pkg.github.com/data443/index.json --build-arg NUGET_API_KEY=${{ secrets.PACKAGE_TOKEN }} -t ${{ env.docker_image_name }}:${{ env.GitVersion_MajorMinorPatch }} -f ${{ env.dockerfile }} --force-rm . +# docker tag ${{ env.docker_image_name }}:${{ env.GitVersion_MajorMinorPatch }} ${{ env.docker_image_name }}:latest +# docker push --all-tags ${{ env.docker_image_name }} +# +# - name: Tag branch +# run: | +# git tag ${{ env.GitVersion_MajorMinorPatch }} +# git push origin ${{ env.GitVersion_MajorMinorPatch }} + + +name: on-push on: push: - branches: [main] + branches: + - 'main' jobs: + gitversion: + runs-on: ubuntu-latest + outputs: + semantic_version: ${{ steps.result.outputs.semver }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: '5.x' + - uses: gittools/actions/gitversion/execute@v1.1.1 + with: + useConfigFile: true + configFilePath: GitVersion.yml + - name: set output + id: result + run: echo "semver=$GitVersion_SemVer" >> "$GITHUB_OUTPUT" + - name: Tag branch + run: | + git tag $GitVersion_SemVer + git push origin $GitVersion_SemVer + build-cs-sdk: + runs-on: ubuntu-latest + needs: gitversion + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Set Version + id: update + uses: vers-one/dotnet-project-version-updater@v1.6 + with: + file: "src/comissions.app.sdk/comissions.app.sdk.csproj" + version: ${{ needs.gitversion.outputs.semantic_version }} + + - name: Authorize NuGet Source + uses: StirlingLabs/GithubNugetAuthAction@main + with: + owner: data443 + name: Data443 + token: ${{secrets.DATA443_PACKAGE_SECRET}} + + - name: Build SDK + run: dotnet build ./src/comissions.app.sdk/comissions.app.sdk.csproj --configuration Release -p:Version=${{needs.gitversion.outputs.semantic_version}} + + - name: Push SDK + run: dotnet nuget push src/comissions.app.sdk/bin/Release/**/*.nupkg --skip-duplicate -s "https://nuget.pkg.github.com/data443/index.json" --api-key ${{secrets.GITHUB_TOKEN}} + + build-js-sdk-build: + runs-on: ubuntu-latest + needs: gitversion + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + + - name: Generate Swagger JSON + run: dotnet build ./src/comissions.app.api/comissions.app.api.csproj --configuration Release + + - name: Generate code + uses: hatamiarash7/openapi-generator@v0.2.0 + with: + generator: javascript + openapi-file: src/comissions.app.sdk/swagger.json + output-dir: ./javascript-client/ + + - uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + node-auth-token: ${{ secrets.GITHUB_TOKEN }} + + - name: "Install Babel" + run: npm install @babel/core @babel/cli @babel/preset-env @babel/plugin-proposal-class-properties @babel/plugin-proposal-json-strings @babel/plugin-proposal-decorators @babel/plugin-proposal-function-sent + + - name: Install dependencies + run: | + cd javascript-client + npm install + + - name: Update dependencies + run: | + cd javascript-client + npm update + + - name: Run Tests + run: | + cd javascript-client + npm test + + - name: Update my-file.json description + uses: jossef/action-set-json-field@v2.1 + with: + file: javascript-client/package.json + field: name + value: "@D4M13N-D3V/comissions.app.sdk" + + - name: 'Change vVersion' + uses: reedyuk/npm-version@1.1.1 + with: + version: '${{needs.gitversion.outputs.semantic_version}}' + package: 'javascript-client/' + git-tag-version: 'false' + + - uses: JS-DevTools/npm-publish@v3 + with: + package : javascript-client/ + token: ${{ secrets.GITHUB_TOKEN }} + registry: "https://npm.pkg.github.com" + + - name: Create Release + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/create-release@v1 + with: + tag_name: v${{ needs.gitversion.outputs.semantic_version }} + release_name: SDK + draft: false + prerelease: false + body: Release of SDK version ${{ needs.gitversion.outputs.semantic_version }} + + - name: Zip JavaScript client folder + run: zip -r dim.api.sdk.zip javascript-client + + - name: Upload Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dim.api.sdk.zip + asset_name: documentation_and_source_code.zip + asset_content_type: application/zip + + - name: Delete unnecessary files in javascript-client folder + run: | + find javascript-client -type f ! -name "*.md" -delete + + - name: Rename .md files to .html + run: | + find javascript-client -type f -name "*.md" -exec bash -c 'mv "$0" "${0%.md}.html"' {} \; + + - name: Add script tag to HTML files + run: | + find javascript-client -type f -name "*.html" -exec sed -i '1i