diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..29245a1 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,105 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{steps.release.outputs.release_created}} + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: simple + package-name: Postal.AspNetCore + + build: + runs-on: ubuntu-latest + needs: release-please + if: ${{ needs.release-please.outputs.release_created }} + strategy: + matrix: + dotnet-version: ["3.1.x", "6.0.x"] + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet ${{ matrix.dotnet-version }} + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ matrix.dotnet-version }} + - name: Display dotnet version + run: dotnet --version + - uses: actions/cache@v3 + with: + path: ~/.nuget/packages + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + - name: Install dependencies + run: dotnet restore + - name: Build + run: dotnet build -c Release Postal.sln + - name: Test + run: dotnet test -c Release + - name: Upload dotnet test results + uses: actions/upload-artifact@v3 + with: + name: dotnet-results-${{ matrix.dotnet-version }} + path: TestResults-${{ matrix.dotnet-version }} + # Use always() to always run this step to publish test results when there are test failures + if: ${{ always() }} + + deploy: + runs-on: ubuntu-latest + needs: [build, release-please] + if: ${{ needs.release-please.outputs.release_created }} + strategy: + matrix: + dest: ["myget", "github"] + source-url: + [ + "https://www.myget.org/F/herman-github/api/v2/package", + "https://nuget.pkg.github.com/hermanho/index.json", + ] + include: + - dest: myget + nuget-auth-token-secret: NUGET_API_KEY + - org: github + nuget-auth-token-secret: GITHUB_TOKEN + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: "6.0.x" + source-url: ${{ matrix.source-url }} + env: + NUGET_AUTH_TOKEN: ${{ secrets[matrix.nuget-auth-token-secret] }} + - name: Display dotnet version + run: dotnet --version + - uses: actions/cache@v3 + with: + path: ~/.nuget/packages + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + - name: Install dependencies + run: dotnet restore + - name: Build + run: dotnet build -c Release Postal.sln + - name: Create the package + run: dotnet pack src/Postal.AspNetCore/Postal.AspNetCore.csproj -c Release + - name: Publish the package to GPR + run: dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fbe11e3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -dist: bionic -language: csharp -mono: none -solution: Postal.sln -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - - DOTNET_CLI_TELEMETRY_OPTOUT=1 -install: - - curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.1.403 - - curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS - - export PATH="$PATH:$HOME/.dotnet" - - dotnet --list-sdks -script: - - export BUILD_SOURCEVERSION=$TRAVIS_COMMIT - - export BUILD_BUILDID=$TRAVIS_BUILD_NUMBER - - echo $BUILD_SOURCEVERSION - - echo $BUILD_BUILDID - - dotnet restore - - dotnet build -c Release Postal.sln - - dotnet test -c Release - - dotnet pack src/Postal.AspNetCore/Postal.AspNetCore.csproj -c Release -deploy: - - provider: script - skip_cleanup: true - script: bash scripts/travis-deploy.sh - on: - branch: master - condition: '"x${NUGET_API_KEY}" != "x" && "x${GH_TOKEN}" != "x"' - - provider: script - skip_cleanup: true - script: bash scripts/travis-deploy.sh - on: - condition: '"x${NUGET_API_KEY}" != "x" && "x${GH_TOKEN}" != "x"' - tags: true -branches: - only: - # Pushes and PR to the master branch - - master - # Ruby regex to match tags. Required, or travis won't trigger deploys when - # a new tag is pushed. Version tags should be of the form: v0.1.0 - - /^v\d+\.\d+\.\d+.*$/ diff --git a/scripts/travis-deploy.sh b/scripts/travis-deploy.sh deleted file mode 100644 index 2d1b262..0000000 --- a/scripts/travis-deploy.sh +++ /dev/null @@ -1,7 +0,0 @@ -# https://github.com/NuGet/Home/issues/8580#issuecomment-555696372 -for f in src/Postal.AspNetCore/bin/Release/*.nupkg -do - curl -vX PUT -u "hermanho:$GH_TOKEN" -F package=@$f https://nuget.pkg.github.com/hermanho/ -done - -dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg --source https://www.myget.org/F/herman-github/api/v2/package --api-key $NUGET_API_KEY \ No newline at end of file diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..56fea8a --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +3.0.0 \ No newline at end of file