Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net]build(gh): introduce release pipeline for .Net #682

Merged
merged 25 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
06daade
[net]build(gh): introduce GH workflow for .Net release
DennisInSky Nov 21, 2024
cf15356
.
DennisInSky Nov 21, 2024
c5733df
build and test .Net
DennisInSky Nov 21, 2024
2d5e86a
split build and test
DennisInSky Nov 21, 2024
3e2d94a
fix artifacts structure
DennisInSky Nov 21, 2024
e490572
artifacts structure
DennisInSky Nov 21, 2024
c5232fa
pack sails.net
DennisInSky Nov 22, 2024
021d9ea
upload nugets as artifacts
DennisInSky Nov 22, 2024
44aef34
fix
DennisInSky Nov 22, 2024
43b7cd5
auth against GH NuGets
DennisInSky Nov 22, 2024
014ec34
fix
DennisInSky Nov 22, 2024
26f6baf
publish nugets
DennisInSky Nov 22, 2024
0faddc2
try gh token as nuget api key
DennisInSky Nov 22, 2024
603e707
test beta version
DennisInSky Nov 22, 2024
040b4ad
yet another publish
DennisInSky Nov 22, 2024
0c0d4e2
Merge branch 'master' into dd/gh-net-release
DennisInSky Nov 26, 2024
23cb056
fix nuget sources setup
DennisInSky Nov 26, 2024
a9d36cb
fix env var
DennisInSky Nov 26, 2024
a7fd40a
Merge remote-tracking branch 'origin/master' into dd/gh-net-release
DennisInSky Nov 27, 2024
8a6e0f4
create release for .net
DennisInSky Nov 27, 2024
d0a14a0
re-enable NuGets publishing
DennisInSky Nov 27, 2024
6877982
Merge remote-tracking branch 'origin/master' into dd/gh-net-release
DennisInSky Nov 27, 2024
36296ff
add publishing to NuGet.org
DennisInSky Nov 27, 2024
fb759ac
Merge remote-tracking branch 'origin/master' into dd/gh-net-release
DennisInSky Nov 27, 2024
be5f118
final version
DennisInSky Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/net-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- 'Sales.Net.sln'

jobs:
build-test:
build_test:
name: Test Managed Code
runs-on: ubuntu-latest
permissions:
Expand Down
198 changes: 197 additions & 1 deletion .github/workflows/net-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}