Skip to content

Merge pull request #31 from hermanho/release-please--branches--main--… #49

Merge pull request #31 from hermanho/release-please--branches--main--…

Merge pull request #31 from hermanho/release-please--branches--main--… #49

name: release-please
on:
push:
branches:
- main
permissions:
contents: write
issues: read
checks: write
pull-requests: write
packages: write
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["7","8"]
steps:
- uses: actions/checkout@v4
- 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 --logger "trx;LogFileName=TestResults-${{ matrix.dotnet-version }}.trx"
- name: Upload dotnet test results
uses: actions/upload-artifact@v3
if: always()
with:
name: dotnet-results-${{ matrix.dotnet-version }}
path: "./**/TestResults/TestResults-${{ matrix.dotnet-version }}.trx"
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "./**/TestResults/TestResults-${{ matrix.dotnet-version }}.trx"
test-pack:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7
8
- name: Display dotnet version
run: dotnet --version
- uses: actions/cache@v4
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: Add SHORT_SHA env property with commit short sha
run: |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
echo "GITHUB_RELEASE=true" >> $GITHUB_ENV
- 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: List src/Postal.AspNetCore/bin/Release/
run: ls -la src/Postal.AspNetCore/bin/Release/
release-please:
runs-on: ubuntu-latest
needs: [test, test-pack]
outputs:
release_created: ${{steps.release.outputs.release_created}}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
deploy:
runs-on: ubuntu-latest
needs: [test, test-pack, release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7
8
- name: Display dotnet version
run: dotnet --version
- uses: actions/cache@v4
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: Add SHORT_SHA env property with commit short sha
run: |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
echo "GITHUB_RELEASE=true" >> $GITHUB_ENV
- 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 myget
run: dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg --source https://www.myget.org/F/herman-github/api/v2/package --api-key ${{ secrets.MYGET_API_KEY }} --skip-duplicate
- name: Publish the package to Github
run: dotnet nuget push src/Postal.AspNetCore/bin/Release/*.nupkg --source https://nuget.pkg.github.com/hermanho/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate