diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..46693b4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [ master, feature/** ] + pull_request: + branches: [ master ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + 10.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj --configuration Release --no-restore + + - name: Build Tests + run: dotnet build tests/MaskedUUID.AspNetCore.Tests/MaskedUUID.AspNetCore.Tests.csproj --configuration Release --no-restore + + - name: Test + run: dotnet test tests/MaskedUUID.AspNetCore.Tests/MaskedUUID.AspNetCore.Tests.csproj --configuration Release --no-build --verbosity normal diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml new file mode 100644 index 0000000..3b3b051 --- /dev/null +++ b/.github/workflows/nuget-publish.yml @@ -0,0 +1,84 @@ +name: Publish to NuGet + +on: + push: + branches: [ release ] + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # タグ取得用 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + 10.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj --configuration Release --no-restore + + - name: Build Tests + run: dotnet build tests/MaskedUUID.AspNetCore.Tests/MaskedUUID.AspNetCore.Tests.csproj --configuration Release --no-restore + + - name: Test + run: dotnet test tests/MaskedUUID.AspNetCore.Tests/MaskedUUID.AspNetCore.Tests.csproj --configuration Release --no-build --verbosity normal + + - name: Calculate Version + id: version + run: | + # csprojからVersionPrefixを取得 + VERSION_PREFIX=$(grep -oP '(?<=)[^<]+' src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj) + echo "VersionPrefix: $VERSION_PREFIX" + + # 前回のタグを取得 + PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -z "$PREV_TAG" ]; then + # タグがない場合は初回リリース + VERSION="${VERSION_PREFIX}.0" + else + # 前回タグからx.yを抽出 + PREV_XY=$(echo $PREV_TAG | sed 's/^v//' | cut -d. -f1,2) + PREV_Z=$(echo $PREV_TAG | sed 's/^v//' | cut -d. -f3) + + if [ "$PREV_XY" = "$VERSION_PREFIX" ]; then + # 同じx.yならzをインクリメント + NEW_Z=$((PREV_Z + 1)) + VERSION="${VERSION_PREFIX}.${NEW_Z}" + else + # 異なるx.yならz=0 + VERSION="${VERSION_PREFIX}.0" + fi + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Package Version: $VERSION" + + - name: Pack + run: dotnet pack src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj + --configuration Release + --output ./nupkg + /p:PackageVersion=${{ steps.version.outputs.version }} + + - name: Publish to NuGet + run: dotnet nuget push ./nupkg/*.nupkg + --api-key ${{ secrets.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --skip-duplicate + + - name: Create Git Tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag v${{ steps.version.outputs.version }} + git push origin v${{ steps.version.outputs.version }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c869c8b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 actbit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj b/src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj index e824bd3..a69a6ca 100644 --- a/src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj +++ b/src/MaskedUUID.AspNetCore/MaskedUUID.AspNetCore.csproj @@ -17,6 +17,22 @@ enable enable Library + true + + + MaskedUUID.AspNetCore + 1.0 + actbit + ASP.NET Core で UUIDv7 のタイムスタンプ部を UUIDv47 アルゴリズムでマスクし、可逆的に変換するライブラリ + uuid;uuidv7;uuidv47;aspnetcore;masking + MIT + README.md + https://github.com/actbit/MaskedUUID + git + + + +