Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
StardustDL committed Jul 9, 2020
1 parent 2b3f678 commit a21944a
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on: [push, pull_request]
on:
push:
pull_request:

defaults:
run:
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion psakefile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit a21944a

Please sign in to comment.