Skip to content

Commit

Permalink
Merge pull request #10 from GitHub-Kieran/gh-release-workflow
Browse files Browse the repository at this point in the history
Gh release workflow
  • Loading branch information
GitHub-Kieran authored Apr 4, 2024
2 parents 2176d06 + 178e8ba commit 6df5096
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 15 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build-and-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build and test

on:
push:
branches: [ '**', '!main' ]
pull_request:
branches: [ '**' ]

jobs:
build-and-unit-test:
uses: ./.github/workflows/reusable-build-and-unit-test.yml
cleanup-workflow-run-logs:
uses: ./.github/workflows/reusable-github-workflow-run-cleanup.yml
needs: build-and-unit-test
permissions:
actions: write
with:
days_old: "0"
runs_to_keep: "2"
54 changes: 54 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create github release

on:
push:
branches: [ 'main' ]

jobs:

build-and-unit-test:
uses: ./.github/workflows/reusable-build-and-unit-test.yml

publish:
runs-on: ${{ matrix.operating-system }}
needs: build-and-unit-test
permissions:
contents: write

strategy:
matrix:
operating-system: [ubuntu-latest]

steps:
- name: Download solution artifact
uses: actions/download-artifact@main
with:
name: Solution artifact
- name: Publish
run: dotnet publish --configuration Release -p:UseAppHost=false --no-build --verbosity normal --output ./dist ./src/FileSorter.Console/FileSorter.Console.csproj

- name: Archive Release
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: file-sorter-v0.${{ github.run_number }}.0-beta.zip
exclusions: '*.git* /*node_modules/* .editorconfig'
path: dist

- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: file-sorter-v0.${{ github.run_number }}.0-beta.zip
tag_name: v0.${{ github.run_number }}.0-beta
prerelease: true
draft: true
generate_release_notes: true

cleanup-workflow-run-logs:
uses: ./.github/workflows/reusable-github-workflow-run-cleanup.yml
needs: publish
permissions:
actions: write
with:
days_old: "0"
runs_to_keep: "2"
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: .NET
name: Build and test

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
workflow_call:

jobs:
build:
Expand All @@ -15,7 +12,8 @@ jobs:
operating-system: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand All @@ -24,11 +22,11 @@ jobs:
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Upload build artifact
- name: Upload solution artifact
uses: actions/upload-artifact@main
with:
name: Build artifact
path: ./test/FileSorter.UnitTest/bin/Release/
name: Solution artifact
path: .
if-no-files-found: error

test:
Expand All @@ -40,11 +38,9 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Download build artifact
- name: Download solution artifact
uses: actions/download-artifact@main
with:
name: Build artifact
- name: Test build artifact download
run: ls -R
- name: Test
run: dotnet test */FileSorter.UnitTest.dll --no-build --verbosity normal
name: Solution artifact
- name: Unit Test
run: dotnet test ./test/FileSorter.UnitTest/bin/Release/*/FileSorter.UnitTest.dll --no-build --verbosity normal
27 changes: 27 additions & 0 deletions .github/workflows/reusable-github-workflow-run-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Clean up workflow runs

on:
workflow_call:
inputs:
days_old:
description: "The amount of days old to delete"
type: string
default: "0"
required: false
runs_to_keep:
description: "The amount of latest workflows runs to keep"
type: string
default: "2"
required: false

jobs:
clean-logs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: igorjs/gh-actions-clean-workflow@v4
with:
days_old: "0"
runs_to_keep: "2"

0 comments on commit 6df5096

Please sign in to comment.