Skip to content

Commit

Permalink
chore: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
moomiji committed Jan 2, 2024
1 parent e810d0e commit cc0909e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ name: cd

on:
workflow_dispatch:
inputs:
Publish:
description: 'Publish option'
required: true
default: 'None'
type: choice
options:
- None
- NuGet
- NuGetTest
push:
branches:
- "**"
Expand All @@ -14,8 +24,9 @@ jobs:
release:
runs-on: windows-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages # need ${{ secrets.NUGET_TOKEN }}
NUGET_PACKAGE_SOURCE: https://api.nuget.org/v3/index.json # https://apiint.nugettest.org/v3/index.json
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages # NuGet CLI environment variables
NUGET_PACKAGE_SOURCE: https://api.nuget.org/v3/index.json # need ${{ secrets.NUGET_TOKEN }} or ${{ secrets.NUGETALL_TOKEN }} (Expires in a day)
NUGETTEST_PACKAGE_SOURCE: https://apiint.nugettest.org/v3/index.json # need ${{ secrets.NUGETTEST_TOKEN }} (Expires in a day)

steps:
- uses: actions/checkout@v3
Expand All @@ -24,7 +35,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0'
dotnet-version: [ '7.0.x', '8.0.x' ]
cache: true
cache-dependency-path: '**/packages.lock.json'
- run: dotnet restore --locked-mode
Expand All @@ -33,6 +44,7 @@ jobs:
shell: bash
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
is_cd_modified=${{ contains(github.event.head_commit.modified, '.github/workflows/cd.yml' }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
if ! $($is_release) ; then
prefix=${tag%-*-*}
Expand All @@ -43,16 +55,22 @@ jobs:
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo version=${tag#v} | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
echo is_cd_modified=$is_cd_modified | tee -a $GITHUB_OUTPUT
- name: Build
run: |
dotnet build --configuration Release --no-restore -p:Version=${{ steps.meta.outputs.version }} -p:RepositoryBranch=$(git rev-parse --abbrev-ref HEAD) -p:RepositoryCommit=$(git rev-parse HEAD)
mv ./src/**/bin/Release/*nupkg ./
- name: Publish the package to nugettest.org
if: ${{ steps.meta.outputs.is_cd_modified == 'true' || github.event.inputs.Publish == 'NuGetTest' }}
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGETTEST_PACKAGE_SOURCE }} --source ${{ env.NUGET_PACKAGE_SOURCE }}

- name: Publish the package to nuget.org
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source ${{ env.NUGET_PACKAGE_SOURCE }}
if: ${{ steps.meta.outputs.is_release == 'true' || github.event.inputs.Publish == 'NuGet' }}
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGETALL_TOKEN }} --source ${{ env.NUGET_PACKAGE_SOURCE }}

- uses: softprops/action-gh-release@v1
if: ${{ steps.meta.outputs.is_release == 'true' }}
with:
tag_name: ${{ steps.meta.outputs.tag }}
tag_name: ${{ steps.meta.outputs.tag }}
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
matrix:
os: windows-latest # [windows-latest, ubuntu-latest, macos-latest]
arch: x86_64 # [aarch64, x86_64]
dotnet: '7.0.x' # [ '7.0.x' ]
dotnet: [ '7.0.x', '8.0.x' ]
fail-fast: false
# env:
# NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages # NuGet CLI environment variables

runs-on: ${{ matrix.os }}
steps:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/smoke-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
runs-on: macos-latest
env:
API_LEVEL: 29
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages # NuGet CLI environment variables

steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0'
dotnet-version: [ '7.0.x', '8.0.x' ]
cache: true
cache-dependency-path: '**/packages.lock.json'
- run: dotnet restore --locked-mode
Expand Down Expand Up @@ -66,4 +66,6 @@ jobs:
if: always()
with:
name: TestResults
path: ./**/TestResults
path: |
./**/TestResults
./src/MaaFramework.Binding.UnitTests/bin/**/debug

0 comments on commit cc0909e

Please sign in to comment.