Skip to content

Commit

Permalink
* update ci script check production (#7)
Browse files Browse the repository at this point in the history
* update ci  script  check production

* formatter

* set_production_env

* update

* prod-check

* check

* production

* 获取github的tag的变量命令

* ges

* a

* check

* if: ${{ github.ref == 'dev-ci-cd-github' }}

* ref_name

* IS_PRODUCTION

* push

* Restore dependencies

* build

* update

* update script

* update ci script

* pack_push

* pack_push

* update

* update CICD_PACKAGE_GITHUB_TOKEN

* update
  • Loading branch information
ltm0203 committed Mar 8, 2024
1 parent 70e1a43 commit 3479d73
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 29 deletions.
74 changes: 49 additions & 25 deletions .github/workflows/Build and pack nuget.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@

name: Build and pack nuget
on:
push:
branches:
- main
- dev-ci-cd-github
tags:
- '*' # 触发所有tag

env:
IS_PRODUCTION: true
# TAG: ${{ github.ref_name }} # 获取当前分支名或tag名
TAG: 1.0.0 # 获取当前分支名或tag名
NUGET_SOURCE: https://api.nuget.org/v3/index.json
NUGET_SOURCE_APIKEY: ${{ secrets.NUGET_TOKEN_YOYOBOOT }}



jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |

build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# 注释掉缓存
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-build-nuget-${{ env.CACHE_NAME }}-
- name: Restore dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Pack with powershell
shell: pwsh
working-directory: ./nupkg
run: ./pack.ps1
- name: Restore dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Pack with powershell
shell: pwsh
working-directory: ./nupkg
run: ./pack.ps1
- name: Push Nuget Package
working-directory: ./nupkg
run: ./pack_push.ps1
shell: pwsh
- name: Push to GitHub Nuget Packages
working-directory: ./nupkg
run: ./pack_push.ps1
shell: pwsh
env:
NUGET_SOURCE: https://nuget.pkg.github.com/yoyoboot/index.json
NUGET_SOURCE_APIKEY: ${{ secrets.CICD_PACKAGE_GITHUB_TOKEN }}






10 changes: 6 additions & 4 deletions nupkg/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ $version = "1.0.0"
# 是否为发布
$isProduction = $env:IS_PRODUCTION

# 打印环境变量 然后将它的颜色设置为蓝色 然后暂停 以便查看
Write-Host "TAG: $env:TAG" -ForegroundColor Blue


Write-Host "IS_PRODUCTION: $isProduction" -ForegroundColor Blue

# 设置输入任意键继续的命令
Read-Host -Prompt "Press Enter to continue"



# 发布模式,从环境变量读取
if ($isProduction -eq $True) {
Write-Host "TAG: $env:TAG" -ForegroundColor Blue

$version = $env:TAG
Write-Host "version: $version"

}

# Paths
Expand Down

0 comments on commit 3479d73

Please sign in to comment.