build-server #374
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-server | |
on: | |
workflow_dispatch: | |
inputs: | |
release-type: | |
description: "Release type" | |
required: true | |
type: choice | |
default: prerelease | |
options: | |
- prerelease | |
- prepatch | |
- preminor | |
- premajor | |
- patch | |
- minor | |
- major | |
jobs: | |
build: | |
runs-on: windows-2022 | |
steps: | |
# ---------------------------------------------------------- | |
# Setup | |
# ---------------------------------------------------------- | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "latest" | |
- name: Corepack | |
run: corepack enable | |
- name: Find pnpm cache | |
id: pnpmcache | |
shell: pwsh | |
run: | | |
$path = pnpm store path | Out-String | |
echo "cachedir=$path" >> $ENV:GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ steps.pnpmcache.outputs.cachedir }} | |
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm- | |
- name: Git configuration | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Actions" | |
# ---------------------------------------------------------- | |
# Version | |
# ---------------------------------------------------------- | |
- name: Bump release version | |
if: startsWith(github.event.inputs.release-type, 'pre') != true | |
shell: bash | |
working-directory: client/insight | |
run: echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV | |
env: | |
RELEASE_TYPE: ${{ github.event.inputs.release-type }} | |
- name: Bump pre-release version | |
if: startsWith(github.event.inputs.release-type, 'pre') | |
shell: bash | |
working-directory: client/insight | |
run: echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE)" >> $GITHUB_ENV | |
env: | |
RELEASE_TYPE: ${{ github.event.inputs.release-type }} | |
# NEW_VERSION is something like v14.0.0 so need to also strip the initial 'v' off | |
- name: Commit package.json changes and create tag | |
shell: pwsh | |
working-directory: client/insight | |
run: | | |
git add "package.json" | |
git commit -m "chore: release $ENV:NEW_VERSION" | |
git tag $ENV:NEW_VERSION | |
echo "NEW_VERSION_NUM=$($ENV:NEW_VERSION.substring(1))" | Out-File -FilePath $ENV:GITHUB_ENV -Append | |
env: | |
NEW_VERSION: ${{ env.NEW_VERSION }} | |
# ---------------------------------------------------------- | |
# Test and Build | |
# ---------------------------------------------------------- | |
- run: pnpm --dir client/insight install --frozen-lockfile | |
- run: pnpm --dir client/insight run test | |
- run: pnpm --dir client/insight run build | |
- name: Server TestSuite | |
run: | | |
tzutil /s "Pacific Standard Time" | |
dotnet test server/test --collect:"XPlat Code Coverage" | |
- name: Build MachineFramework | |
run: dotnet pack -c Release --include-symbols /p:Version="${{ env.NEW_VERSION_NUM }}" server/lib/BlackMaple.MachineFramework | |
- name: Build Mazak | |
run: dotnet pack -c Release --include-symbols /p:Version="${{ env.NEW_VERSION_NUM }}" server/machines/mazak | |
- name: Build Makino | |
run: dotnet pack -c Release --include-symbols /p:Version="${{ env.NEW_VERSION_NUM }}" server/machines/makino | |
- name: Build Niigata | |
run: dotnet pack -c Release --include-symbols /p:Version="${{ env.NEW_VERSION_NUM }}" server/machines/niigata | |
# ---------------------------------------------------------- | |
# Publish | |
# ---------------------------------------------------------- | |
- name: Publish MachineFramework | |
run: dotnet nuget push -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json server\lib\BlackMaple.MachineFramework\bin\Release\*.nupkg | |
- name: Publish Mazak | |
run: dotnet nuget push -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json server\machines\mazak\bin\Release\*.nupkg | |
- name: Publish Makino | |
run: dotnet nuget push -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json server\machines\makino\bin\Release\*.nupkg | |
- name: Publish Niigata | |
run: dotnet nuget push -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json server\machines\niigata\bin\Release\*.nupkg | |
# ---------------------------------------------------------- | |
# Create Release | |
# ---------------------------------------------------------- | |
- name: Push version commit to git | |
run: | | |
git push origin && git push --tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# ---------------------------------------------------------- | |
# Cleanup | |
# ---------------------------------------------------------- | |
- name: Clean pnpm | |
run: pnpm store prune |