Skip to content

Commit

Permalink
attempt to add build and release steps
Browse files Browse the repository at this point in the history
  • Loading branch information
krogenth committed Aug 11, 2024
1 parent 103122b commit 6df5b40
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Job

on: [pull_request, push]

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
dotnet-version: [ '8.0.x' ]
configuration: [ Debug, Release ]

steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install Dependencies
run: dotnet restore

- name: Build
run: dotnet build -c ${{ matrix.configuration }}
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release Job

on:
push:
branches: [ main ]

concurrency: release

env:
SOLUTION_FILE_PATH: .
BASE_VERSION: 0.1
RELEASE_DIRECTORY: "release_output"
PUBLISH_DIRECTORY: "publish"

jobs:
tag:
name: Create Release Tag
runs-on: ubuntu-latest
steps:
- name: Get Version Info
id: version_info
run: |
echo "build_version=${{ env.BASE_VERSION }}.${{ github.run_number }}" >> $GITHUB_OUTPUT
shell: bash

- name: Create Tag
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.version_info.outputs.build_version }}',
sha: context.sha
})
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
dotnet-version: [ '8.0.x' ]
configuration: [ Release ]
os: [ windows-latest ]
include:
- os: windows-latest
OS_NAME: Windows x64
DOTNET_RUNTIME_IDENTIFIER: win-x64
RELEASE_ZIP_OS_NAME: win_x64

steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Get Version Info
id: version_info
run: |
echo "build_version=${{ env.BASE_VERSION }}.${{ github.run_number }}" >> $GITHUB_OUTPUT
echo "git_short_hash=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
shell: bash

- name: Create Output Directory
run: "mkdir ${{ env.RELEASE_DIRECTORY }}"

- name: Run Publish
run: |
dotnet publish -c Release -r "${{ matrix.DOTNET_RUNTIME_IDENTIFIER }}" -o ./${{ env.PUBLISH_DIRECTORY }} -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded OpenShock.VoiceRecognizer --self-contained
- name: Pack Windows Build
if : matrix.os == 'windows-latest'
run: |
7z a ./${{ env.RELEASE_DIRECTORY }}/OpenShock.VoiceRecognizer-${{ steps.version_info.outputs.build_version }}-win_x64.zip ./${{ env.PUBLISH_DIRECTORY }}
shell: bash

- name: Push Release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.version_info.outputs.build_version }}
artifacts: "${{ env.RELEASE_DIRECTORY }}/*.tar.gz,${{ env.RELEASE_DIRECTORY }}/*.zip"
tag: ${{ steps.version_info.outputs.build_version }}
allowUpdates: true
omitBodyDuringUpdate: true
replacesArtifacts: true

0 comments on commit 6df5b40

Please sign in to comment.