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

Feature: Distribute Types Package #23

Merged
merged 6 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
91 changes: 91 additions & 0 deletions .github/workflows/publish-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish SDK

on:
push:
branches: main

jobs:
check-version:
outputs:
sdk-version-exists: ${{ steps.check-version.outputs.sdk-version-exists }}
current-sdk-version: ${{ steps.check-version.outputs.current-sdk-version }}
types-version-exists: ${{ steps.check-version.outputs.types-version-exists }}
current-types-version: ${{ steps.check-version.outputs.current-types-version }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- id: check-version
env:
GH_TOKEN: ${{ github.token }}
run: |
sudo apt install xq

sdk_version=$(xq Mortein/Mortein.csproj --xpath '/Project/PropertyGroup/FileVersion')
types_version=$(xq Mortein.Types/Mortein.Types.csproj --xpath '/Project/PropertyGroup/Version')

echo current-sdk-version=${sdk_version} >> $GITHUB_OUTPUT
echo current-types-version=${types_version} >> $GITHUB_OUTPUT

(gh release list --repo deco3801-mortein/api --json tagName --jq '.[].tagName' \
| (grep --fixed-strings "v${sdk_version}" > /dev/null) \
&& echo sdk-version-exists=true || echo sdk-version-exists=false) >> $GITHUB_OUTPUT

(gh api /orgs/deco3801-mortein/packages/nuget/Mortein.Types/version --jq '.[].name' \
| (grep --fixed-strings "${types_version}" > /dev/null) \
&& echo types-version-exists=true || echo types-version-exists=false) >> $GITHUB_OUTPUT

release-sdk:
environment: deployment
if: ${{ ! fromJson(needs.check-version.outputs.sdk-version-exists) }}
needs: check-version
permissions:
contents: write
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
cache: true
cache-dependency-path: Mortein*/packages.lock.json
- run: dotnet restore
- run: dotnet tool restore

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- run: npm clean-install

- run: ./generate-sdk.sh
- run: gh release create --generate-notes "v${VERSION}" "mortein-sdk/dist/mortein-sdk-${VERSION}.tgz"
env:
GH_TOKEN: ${{ github.token }}
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_SDK_PAT }}
VERSION: ${{ needs.check-version.outputs.current-sdk-version }}

publish-types:
environment: deployment
if: ${{ ! fromJson(needs.check-version.outputs.types-version-exists) }}
needs: check-version
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
cache: true
cache-dependency-path: Mortein*/packages.lock.json
- run: dotnet restore
- run: dotnet tool restore

- run: dotnet pack Mortein.Types
- run: dotnet nuget push Mortein.Types/bin/Release/Mortein.Types.${VERSION}.nupkg --api-key ${{ github.token }}
env:
VERSION: ${{ needs.check-version.outputs.current-types-version }}
58 changes: 0 additions & 58 deletions .github/workflows/publish-sdk.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Mortein.Types/Mortein.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>

<FileVersion>0.0.1</FileVersion>
<Version>0.0.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
15 changes: 15 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<config>
<add key="defaultPushSource" value="github" />
</config>
<packageSources>
<add key="github" value="https://nuget.pkg.github.com/deco3801-mortein/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="deco3801-mortein" />
<add key="ClearTextPassword" value="password" />
</github>
</packageSourceCredentials>
</configuration>