Skip to content

ci: optimize workflows #86

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

Merged
merged 2 commits into from
Feb 14, 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
16 changes: 5 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
Expand All @@ -26,15 +29,12 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 2
filter: blob:none # We don't need all blobs

- uses: actions/[email protected]
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') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
# restore-keys: |
# ${{ runner.os }}-nuget

- name: restore
run: dotnet restore
Expand All @@ -55,9 +55,6 @@ jobs:
needs: [test]
runs-on: windows-latest
timeout-minutes: 15
permissions:
packages: write
contents: write

env:
CONFIGURATION: Release
Expand All @@ -66,15 +63,12 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # needed so minver finds git tags https://github.com/actions/checkout/issues/172
filter: blob:none # We don't need all blobs

- uses: actions/[email protected]
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') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
# restore-keys: |
# ${{ runner.os }}-nuget

- name: restore
run: dotnet restore
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ env:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
cancel-in-progress: false

permissions:
contents: read

jobs:
release:
runs-on: windows-latest
timeout-minutes: 15
permissions:
packages: write
contents: write

env:
Expand All @@ -29,15 +31,14 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # needed so minver finds git tags https://github.com/actions/checkout/issues/172
filter: blob:none # We don't need all blobs

- uses: actions/[email protected]
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') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
# restore-keys: |
# ${{ runner.os }}-nuget
restore-keys: |
${{ runner.os }}-nuget

- name: restore
run: dotnet restore
Expand All @@ -53,23 +54,24 @@ jobs:
name: packages
path: bin/*.nupkg

# - name: deploy github.com
# run: |
# dotnet nuget add source --username $NUGET_USR --password $NUGET_PSW --store-password-in-clear-text --name github $NUGET_SOURCE
# find bin -name '*.nupkg' | xargs dotnet nuget push -s github --skip-duplicate --force-english-output
# shell: bash
# env:
# NUGET_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
# NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}

- name: deploy nuget.org
run: find bin -name '*.nupkg' | xargs dotnet nuget push -s $NUGET_SOURCE -k $NUGET_KEY --skip-duplicate --force-english-output
shell: bash
env:
NUGET_SOURCE: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}

- name: prepare version
run: echo VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_ENV

- uses: marvinpinto/[email protected]
- name: Generate changelog with git-cliff
uses: tj-actions/git-cliff@b8b856ab6829a813d4ed58476b6faaec9c2b24ef # v1.4.2
with:
args: --latest --strip all
output: 'CHANGELOG.md'

- uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: 'CHANGELOG.md'
name: ${{ env.VERSION }}
prerelease: ${{ contains(github.ref_name, '-') }}