Skip to content

Commit b20f792

Browse files
committed
add release workflow (squash)
1 parent 781c3a1 commit b20f792

File tree

23 files changed

+1482
-1309
lines changed

23 files changed

+1482
-1309
lines changed

.github/workflows/build-and-test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: build-and-test
2+
on:
3+
pull_request:
4+
branches:
5+
- '**'
6+
workflow_call:
7+
jobs:
8+
build:
9+
uses: ./.github/workflows/build.yml
10+
test:
11+
uses: ./.github/workflows/test.yml
12+
needs: [build]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: build-test-and-pre-release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build:
8+
uses: ./.github/workflows/build.yml
9+
test:
10+
uses: ./.github/workflows/test.yml
11+
needs: [build]
12+
publish-pre-release:
13+
uses: ./.github/workflows/pre-release.yml
14+
needs: [build,test]
15+
with:
16+
versionid: ${{ needs.build.outputs.versionid }}

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: build
2+
on:
3+
workflow_call:
4+
outputs:
5+
versionid:
6+
description: The version ID of the build
7+
value: ${{ jobs.build.outputs.versionid }}
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
outputs:
12+
versionid: ${{ steps.build-step.outputs.versionid }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Setup .NET CLI
16+
uses: actions/setup-dotnet@v3
17+
with:
18+
dotnet-version: 7.0.x
19+
- name: Restore dependencies
20+
run: dotnet restore
21+
- name: Build
22+
id: build-step
23+
shell: pwsh
24+
run: |
25+
# Start the build and store all output (letting it also be printed to the console)
26+
$output = ""
27+
. .\Support\Build.ps1 Release ${{ github.sha }} | Tee-Object -Variable output
28+
29+
# Get the version ID from the last line of the output
30+
$versionId = $output | Select-Object -Last 1
31+
32+
# Set the output variable for this step
33+
echo "versionid=$versionId" >> $env:GITHUB_OUTPUT
34+
- name: Cache the build output
35+
uses: actions/cache@v3
36+
with:
37+
path: |
38+
${{ github.workspace }}\bin
39+
${{ github.workspace }}\Support\Key2Joy.Tests\bin\Key2Joy.Tests
40+
key: ${{ runner.os }}-build-${{ github.sha }}
41+
restore-keys: |
42+
${{ runner.os }}-build-

.github/workflows/pre-release.yml

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
1-
name: pre-release
2-
on:
3-
workflow_run:
4-
workflows: [tests]
5-
types: [completed]
6-
branches:
7-
- '**'
8-
jobs:
9-
on-tests-failed:
10-
runs-on: windows-latest
11-
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
12-
steps:
13-
- run: echo 'The triggering workflow failed'
14-
on-tests-passed-build:
15-
runs-on: windows-latest
16-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17-
permissions:
18-
contents: write
19-
steps:
20-
- run: echo 'The triggering workflow passed, building a pre-release'
21-
- uses: actions/checkout@v3
22-
- name: Setup .NET CLI
23-
uses: actions/setup-dotnet@v3
24-
with:
25-
dotnet-version: 7.0.x
26-
- name: Build to output
27-
id: build-step
28-
shell: pwsh
29-
run: echo ([string]::Join("","VERSION_ID=",((&".\Support\Build.ps1" Release ${{ github.event.workflow_run.head_commit.id }}) | Select-Object -Last 1))) >> "$GITHUB_OUTPUT"
30-
- name: Archive Pre-release
31-
uses: thedoctor0/[email protected]
32-
with:
33-
type: 'zip'
34-
path: 'bin\Key2Joy.Gui\Release'
35-
filename: 'pre-release.zip'
36-
- name: Create GitHub Pre-release
37-
uses: ncipollo/release-action@v1
38-
env:
39-
BUILD_VERSION_ID: ${{ steps.build-step.outputs.VERSION_ID }}
40-
with:
41-
token: ${{ secrets.GITHUB_TOKEN }}
42-
name: ${{ env.BUILD_VERSION_ID }}
43-
tag: ${{ env.BUILD_VERSION_ID }}
44-
prerelease: true
45-
generateReleaseNotes: true
46-
artifacts: 'pre-release.zip'
47-
body: |
48-
# 🔧 ${{ env.BUILD_VERSION_ID }}
49-
This release was automatically generated based on the last successful test run.
50-
51-
This version of Key2Joy is not ready for use, but can be used for testing purposes.
1+
name: pre-release
2+
on:
3+
workflow_call:
4+
inputs:
5+
versionid:
6+
description: 'The version ID of the pre-release'
7+
required: true
8+
type: string
9+
jobs:
10+
publish-pre-release:
11+
runs-on: windows-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- run: echo 'The triggering workflow passed, building a pre-release'
16+
- uses: actions/checkout@v3
17+
- name: Restore build from cache
18+
uses: actions/cache@v3
19+
with:
20+
path: |
21+
${{ github.workspace }}\bin
22+
${{ github.workspace }}\Support\Key2Joy.Tests\bin\Key2Joy.Tests
23+
key: ${{ runner.os }}-build-${{ github.sha }}
24+
restore-keys: |
25+
${{ runner.os }}-build-
26+
- name: Archive Pre-release
27+
uses: thedoctor0/[email protected]
28+
with:
29+
type: 'zip'
30+
path: 'bin\Key2Joy.Gui\Release'
31+
filename: 'pre-release.zip'
32+
- name: Create GitHub Pre-release
33+
uses: ncipollo/release-action@v1
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
name: ${{ inputs.versionid }}
37+
tag: ${{ inputs.versionid }}
38+
prerelease: true
39+
generateReleaseNotes: true
40+
artifacts: 'pre-release.zip'
41+
body: |
42+
# 🔧 ${{ inputs.versionid }}
43+
This release was automatically generated based on the last successful test run.
44+
45+
This version of Key2Joy is not ready for use, but can be used for testing purposes.

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: test
2+
on:
3+
workflow_call:
4+
jobs:
5+
run-tests:
6+
runs-on: windows-latest
7+
steps:
8+
- run: echo 'The triggering workflow passed, testing it'
9+
- uses: actions/checkout@v3
10+
- name: Setup .NET CLI
11+
uses: actions/setup-dotnet@v3
12+
with:
13+
dotnet-version: 7.0.x
14+
- name: Restore dependencies
15+
run: dotnet restore
16+
- name: Restore build from cache
17+
uses: actions/cache@v3
18+
with:
19+
path: |
20+
${{ github.workspace }}\bin
21+
${{ github.workspace }}\Support\Key2Joy.Tests\bin\Key2Joy.Tests
22+
key: ${{ runner.os }}-build-${{ github.sha }}
23+
restore-keys: |
24+
${{ runner.os }}-build-
25+
- name: Run Key2Joy Tests
26+
run: dotnet test --no-build --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat="lcov" /p:CoverletOutput="${{ github.workspace }}/coverage/lcov.info"
27+
- name: Coveralls for Key2Joy
28+
uses: coverallsapp/github-action@v2

.github/workflows/tests.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)