diff --git a/.github/workflows/net-ci.yml b/.github/workflows/net-ci.yml index 0c9cd949..b1485d48 100644 --- a/.github/workflows/net-ci.yml +++ b/.github/workflows/net-ci.yml @@ -16,7 +16,7 @@ on: - 'Sales.Net.sln' jobs: - build-test: + build_test: name: Test Managed Code runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/net-release.yml b/.github/workflows/net-release.yml index 6e66f7b1..3e06f039 100644 --- a/.github/workflows/net-release.yml +++ b/.github/workflows/net-release.yml @@ -5,18 +5,214 @@ on: tags: - 'net/v*-pin' +env: + # see https://api.github.com/users/github-actions%5Bbot%5D + GITHUB_USER_NAME: github-actions[bot] + GITHUB_USER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + jobs: prepare: - name: Prepare Release + name: Prepare Release + runs-on: ubuntu-latest + permissions: + contents: write + defaults: + run: + shell: bash + outputs: + r_version: ${{ steps.release_info.outputs.version }} + r_tag: net/v${{ steps.release_info.outputs.version }} + pin_tag: ${{ steps.release_info.outputs.pin_tag }} + + steps: + - name: Extract Release Info + id: release_info + run: | + PIN_TAG=${GITHUB_REF#refs/tags/} + VERSION=${PIN_TAG#net/v} + VERSION="${VERSION%-pin}" + if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]]; then + echo "'$VERSION' is not a valid semver version" + exit 1 + fi + echo "Pin Tag: $PIN_TAG" + echo "pin_tag=$PIN_TAG" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + build_win_x64: + name: Build Native Libraries for Win x64 + needs: prepare + runs-on: windows-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build & Test Client Generator + run: | + cargo build --locked --manifest-path net/rs/Cargo.toml --release + cargo test --locked --manifest-path net/rs/Cargo.toml --release + mkdir -p ./net/rs/target/artifacts/win-x64 + cp ./net/rs/target/release/sails_net_client_gen.dll ./net/rs/target/artifacts/win-x64 + + - name: Upload Client Generator Artifacts + uses: actions/upload-artifact@v4 + with: + name: native_client_gen_win_x64 + path: ./net/rs/target/artifacts + + build_linux_x64: + name: Build Native Libraries for Linux x64 + needs: prepare + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build & Test Client Generator + run: | + cargo build --locked --manifest-path net/rs/Cargo.toml --release + cargo test --locked --manifest-path net/rs/Cargo.toml --release + mkdir -p ./net/rs/target/artifacts/linux-x64 + cp ./net/rs/target/release/libsails_net_client_gen.so ./net/rs/target/artifacts/linux-x64 + + - name: Upload Client Generator Artifacts + uses: actions/upload-artifact@v4 + with: + name: native_client_gen_linux_x64 + path: ./net/rs/target/artifacts + + build_osx_x64: + name: Build Native Libraries for NacOS x64 + needs: prepare + runs-on: macos-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build & Test Client Generator + run: | + rustup target add x86_64-apple-darwin + cargo build --locked --manifest-path net/rs/Cargo.toml --release --target x86_64-apple-darwin + cargo test --locked --manifest-path net/rs/Cargo.toml --release --target x86_64-apple-darwin + mkdir -p ./net/rs/target/artifacts/osx-x64 + cp ./net/rs/target/x86_64-apple-darwin/release/libsails_net_client_gen.dylib ./net/rs/target/artifacts/osx-x64 + + - name: Upload Client Generator Artifacts + uses: actions/upload-artifact@v4 + with: + name: native_client_gen_osx_x64 + path: ./net/rs/target/artifacts + + build_osx_arm64: + name: Build Native Libraries for MacOS ARM64 + needs: prepare + runs-on: macos-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build & Test Client Generator + run: | + rustup target add aarch64-apple-darwin + cargo build --locked --manifest-path net/rs/Cargo.toml --release --target aarch64-apple-darwin + cargo test --locked --manifest-path net/rs/Cargo.toml --release --target aarch64-apple-darwin + mkdir -p ./net/rs/target/artifacts/osx-arm64 + cp ./net/rs/target/aarch64-apple-darwin/release/libsails_net_client_gen.dylib ./net/rs/target/artifacts/osx-arm64 + + - name: Upload Client Generator Artifacts + uses: actions/upload-artifact@v4 + with: + name: native_client_gen_osx_arm64 + path: ./net/rs/target/artifacts + + publish: + name: Publish NuGet Packages + needs: + - prepare + - build_win_x64 + - build_linux_x64 + - build_osx_x64 + - build_osx_arm64 + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download Native Libraries + uses: actions/download-artifact@v4 + with: + path: native_client_gens + pattern: native_client_gen_* + merge-multiple: true + + - name: Build Solution + run: | + dotnet build --configuration Release -p:LibraryRoot=${{ github.workspace }}/native_client_gens + + - name: Test Solution + run: | + dotnet test --no-build --configuration Release --logger "trx;LogFileName=TestResults.trx" + + - name: Pack NuGet Packages + run: | + dotnet pack ./net/src/Sails.Net/Sails.Net.csproj --no-build --configuration Release --output ./nugets \ + -p:Version=${{ needs.prepare.outputs.r_version }} \ + -p:PackageVersion=${{ needs.prepare.outputs.r_version }} \ + -p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} \ + -p:Authors=Gear + dotnet pack ./net/src/Sails.ClientGenerator/Sails.ClientGenerator.csproj --no-build --configuration Release --output ./nugets \ + -p:Version=${{ needs.prepare.outputs.r_version }} \ + -p:PackageVersion=${{ needs.prepare.outputs.r_version }} \ + -p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} \ + -p:Authors=Gear + + - name: Publish NuGet Packages to NuGet.org + run: | + dotnet nuget push ./nugets/*.nupkg \ + --source https://api.nuget.org/v3/index.json \ + --api-key ${{ secrets.NUGET_ORG_API_KEY }} + + release: + name: Create Release runs-on: ubuntu-latest permissions: contents: write + needs: + - prepare + - publish defaults: run: shell: bash + env: + R_NAME: Sails-Net v${{ needs.prepare.outputs.r_version }} steps: - name: Checkout Code uses: actions/checkout@v4 + + - name: Create Release Tag + run: | + R_TAG=${{ needs.prepare.outputs.r_tag }} + git config user.name "$GITHUB_USER_NAME" + git config user.email "$GITHUB_USER_EMAIL" + git tag -a "$R_TAG" -m "Release .Net v${{ needs.prepare.outputs.r_version }}" + git push origin "$R_TAG" + git push origin --delete "${{ needs.prepare.outputs.pin_tag }}" + + - name: Create Draft Release + uses: softprops/action-gh-release@v2 with: + name: ${{ env.R_NAME }} + tag_name: ${{ needs.prepare.outputs.r_tag }} + draft: true + body: | + :exclamation: This is a draft release. + :exclamation: Please write/generate change notes and publish the release. + fail_on_unmatched_files: true token: ${{ secrets.GITHUB_TOKEN }}