From a21944ad1eb95cbaaf6faf801c5c018ed1b2dba2 Mon Sep 17 00:00:00 2001 From: StardustDL Date: Thu, 9 Jul 2020 21:25:58 +0800 Subject: [PATCH] add release workflow --- .github/workflows/ci.yml | 4 +- .github/workflows/release.yml | 102 ++++++++++++++++++++++++++++++++++ psakefile.ps1 | 12 +++- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 561b807..3835f58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ name: CI -on: [push, pull_request] +on: + push: + pull_request: defaults: run: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..72012eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,102 @@ +name: Release + +on: + release: + types: [released] + +defaults: + run: + shell: pwsh + +env: + dotnet-version: "3.1.x" + node-version: "12.x" + build_version: "0.0.1.${{ github.run_number }}" + +jobs: + pub-images: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.dotnet-version }} + - name: Setup NodeJS + uses: actions/setup-node@v1 + with: + node-version: ${{ env.node-version }} + - name: Setup psake + run: Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; Install-Module -Name psake + - name: CD + env: + NUGET_AUTH_TOKEN: ${{ secrets.AZ_TOKEN }} + run: Invoke-psake cd-build -parameters @{ "NUGET_AUTH_TOKEN" = $env:NUGET_AUTH_TOKEN ; "build_version" = $env:build_version } + - name: Generate build status + run: | + cd src/client/AcBlog.Client.WebAssembly.Host || exit $LASTEXITCODE + echo "{ ""Build"": { ""Commit"": ""$env:GITHUB_SHA"", ""Branch"": ""$env:GITHUB_REF"", ""BuildDate"": ""$(date)"", ""Repository"": ""$env:GITHUB_REPOSITORY"", ""Version"": ""$env:build_version"" } }" > ./build.json || exit $LASTEXITCODE + cd ../AcBlog.Client.WebAssembly || exit $LASTEXITCODE + echo "{ ""Build"": { ""Commit"": ""$env:GITHUB_SHA"", ""Branch"": ""$env:GITHUB_REF"", ""BuildDate"": ""$(date)"", ""Repository"": ""$env:GITHUB_REPOSITORY"", ""Version"": ""$env:build_version"" } }" > ./wwwroot/build.json || exit $LASTEXITCODE + - name: Publish Client.WebAssembly + env: + NUGET_AUTH_TOKEN: ${{ secrets.AZ_TOKEN }} + run: Invoke-psake publish-wasm -parameters @{ "NUGET_AUTH_TOKEN" = $env:NUGET_AUTH_TOKEN ; "build_version" = $env:build_version } + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: wasm + path: ./src/client/AcBlog.Client.WebAssembly/publish + - name: Push Client.WebAssembly image + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: acblog/wasm + tag_with_ref: true + dockerfile: ./src/client/AcBlog.Client.WebAssembly/Dockerfile + - name: Push Client.WebAssembly.Host image + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: acblog/wasm-host + tag_with_ref: true + dockerfile: ./src/client/AcBlog.Client.WebAssembly.Host/Dockerfile + - name: Push Server.Api image + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: acblog/api + tag_with_ref: true + dockerfile: ./src/AcBlog.Server.Api/Dockerfile + pub-pkgs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.dotnet-version }} + - name: Setup NodeJS + uses: actions/setup-node@v1 + with: + node-version: ${{ env.node-version }} + - name: Setup psake + run: Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; Install-Module -Name psake + - name: CD + env: + NUGET_AUTH_TOKEN: ${{ secrets.AZ_TOKEN }} + run: Invoke-psake cd -parameters @{ "NUGET_AUTH_TOKEN" = $env:NUGET_AUTH_TOKEN ; "build_version" = $env:build_version } + - name: Publish + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} + run: Invoke-psake deploy-packages-release -parameters @{ "NUGET_AUTH_TOKEN" = $env:NUGET_AUTH_TOKEN ; "build_version" = $env:build_version } + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: packages + path: ./packages \ No newline at end of file diff --git a/psakefile.ps1 b/psakefile.ps1 index b90483e..4bb09f5 100644 --- a/psakefile.ps1 +++ b/psakefile.ps1 @@ -11,7 +11,7 @@ Task CI -depends Install-deps, Restore, Build, Test, Benchmark, Report Task CD -depends CD-Build, Pack, Deploy -Task CD-Build -depends Install-deps, Restore, Build +Task CD-Build -depends Install-deps, Restore, Build, Pack Task Restore -depends Restore-WASM { Exec { dotnet restore } @@ -90,6 +90,16 @@ Task Deploy-packages { Exec { dotnet nuget push ./packages/AcBlog.Tools.Sdk.$build_version.nupkg -s aza -k az } } +Task Deploy-packages-release { + Exec { dotnet nuget push ./packages/AcBlog.Data.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Data.Extensions.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Data.Documents.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.FileSystem.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Data.Repositories.SQLServer.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Sdk.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } + Exec { dotnet nuget push ./packages/AcBlog.Tools.Sdk.$build_version.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_AUTH_TOKEN } +} + Task Restore-WASM { Set-Location src/client/AcBlog.Client.WebAssembly Exec { npm ci }