This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
Merge pull request #9 from devklick/dev #19
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: publish | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-test: | |
# Builds and tests the solution | |
# Identifies the next release version number, if there is one | |
runs-on: ubuntu-latest | |
outputs: | |
next-release-version: ${{steps.capture-next-version.outputs.NEXT_RELEASE_VERSION}} | |
branch-name: ${{ github.head_ref || github.ref_name }} | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
- name: Install Node dependencies | |
run: npm install | |
- name: Setup .Net | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "8.0.x" | |
- name: Install .Net dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build | |
- name: Test | |
run: dotnet test | |
- name: Fetch next version | |
id: fetch-next-version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npx semantic-release --branches ${{env.BRANCH_NAME}} --dry-run | |
- name: Capture next version | |
id: capture-next-version | |
# RELEASE_VERSION by semantic-release in previous step, see .releaserc.json | |
run: echo "NEXT_RELEASE_VERSION=${{env.RELEASE_VERSION}}" >> $GITHUB_OUTPUT | |
publish-and-release: | |
# Publishes, packages and releases the next version, | |
# only if one has been defined in the previous job. | |
# This job will only run on the main branch | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: ${{needs.build-and-test.outputs.next-release-version && | |
needs.build-and-test.outputs.branch-name == 'master'}} | |
env: | |
RELEASE_VERSION: ${{needs.build-and-test.outputs.next-release-version}} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
- name: Install Node dependencies | |
run: npm install | |
- name: Setup .Net | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "8.0.x" | |
- name: Run publish Windows | |
run: dotnet publish -c release -r win-x64 ./src/GDMan.Cli "-p:Version=${{ env.RELEASE_VERSION }}" -o build/win-x64 | |
- name: ZIP Windows output | |
run: cd build/win-x64 && zip -r ../GDMan_win-x64.zip * && cd ../.. | |
- name: Run publish Linux | |
run: dotnet publish -c release -r linux-x64 ./src/GDMan.Cli -p:Version=${{ env.RELEASE_VERSION }} -o build/linux-x64 | |
- name: ZIP Linux output | |
run: cd build/linux-x64 && zip -r ../GDMan_linux-x64.zip * && cd ../.. | |
- name: Run publish OSX | |
run: dotnet publish -c release -r osx-x64 ./src/GDMan.Cli -p:Version=${{ env.RELEASE_VERSION }} -o build/osx-x64 | |
- name: ZIP OSX output | |
run: cd build/osx-x64 && zip -r ../GDMan_osx-x64.zip * && cd ../.. | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release --branches master |