Skip to content

Commit 12df616

Browse files
Split release to separate steps.
1 parent d36b5cf commit 12df616

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
name: Build and Package All Runtimes
1+
name: Build and Release
22

33
on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version tag (e.g. v1.0.0)'
7+
description: 'Version tag (e.g. V1.0.0)'
88
required: true
9-
default: 'v1.0.0'
9+
default: 'V1.0.0'
1010
push:
1111
tags:
1212
- 'v*'
1313

1414
jobs:
15-
build:
15+
create_release_job:
1616
runs-on: ubuntu-latest
17-
timeout-minutes: 30
18-
env:
19-
FRAMEWORK: net8.0
20-
PROJECT: ConvertApi.Cli/ConvertApi.Cli.csproj
21-
TAG_NAME: ${{ github.ref_name }}
17+
outputs:
18+
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
# - name: Setup .NET SDK
24+
# uses: actions/setup-dotnet@v4
25+
# with:
26+
# dotnet-version: '8.x'
27+
28+
# Run tests
29+
# - name: Test
30+
# run: dotnet test ConvertApi.Cli.Tests
31+
32+
- name: Create Release
33+
id: create_release
34+
uses: actions/create-release@v1
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
with:
38+
tag_name: ${{ github.ref_name }} # or an input if workflow_dispatch
39+
release_name: ${{ github.ref_name }}
40+
draft: false
41+
prerelease: false
2242

43+
build_and_upload:
44+
runs-on: ubuntu-latest
45+
needs: create_release_job
2346
strategy:
2447
matrix:
2548
runtime: [ "win-x64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ]
26-
2749
steps:
2850
- name: Checkout
2951
uses: actions/checkout@v4
@@ -33,13 +55,9 @@ jobs:
3355
with:
3456
dotnet-version: '8.x'
3557

36-
# Run tests
37-
# - name: Test
38-
# run: dotnet test ConvertApi.Cli.Tests
39-
4058
- name: Publish for ${{ matrix.runtime }}
4159
run: |
42-
dotnet publish ${{ env.PROJECT }} \
60+
dotnet publish ConvertApi.Cli/ConvertApi.Cli.csproj \
4361
-c Release \
4462
-r ${{ matrix.runtime }} \
4563
--self-contained true \
@@ -48,39 +66,16 @@ jobs:
4866
/p:DebugType=none \
4967
/p:DebugSymbols=false
5068
51-
# - name: Upload artifact for ${{ matrix.runtime }}
52-
# uses: actions/upload-artifact@v3
53-
# with:
54-
# name: convertApi-cli-${{ matrix.runtime }}
55-
# path: ConvertApi.Cli/bin/Release/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish
56-
# retention-days: 1
57-
58-
# Use a step that archives the published files. This ensures we upload a zip asset.
59-
- name: Zip package for ${{ matrix.runtime }}
69+
- name: Zip package
6070
run: |
61-
cd ConvertApi.Cli/bin/Release/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish
62-
zip -r ../../../../../convertApi-cli-${{ matrix.runtime }}.zip ./*
63-
64-
# Create or update the release only once at first matrix job (not on each matrix job).
65-
- name: Create Release
66-
if: ${{ matrix.runtime == 'win-x64' }}
67-
id: create_release
68-
uses: actions/create-release@v1
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
with:
72-
tag_name: ${{ env.TAG_NAME }}
73-
release_name: ${{ env.TAG_NAME }}
74-
draft: false
75-
prerelease: false
71+
zip -j convertApi-cli-${{ matrix.runtime }}.zip ConvertApi.Cli/bin/Release/net8.0/${{ matrix.runtime }}/publish/*
7672
77-
# Upload each runtime's asset to the newly created release.
7873
- name: Upload Release Asset
7974
uses: actions/upload-release-asset@v1
8075
env:
8176
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8277
with:
83-
upload_url: ${{ steps.create_release.outputs.upload_url }}
78+
upload_url: ${{ needs.create_release_job.outputs.release_upload_url }}
8479
asset_path: ./convertApi-cli-${{ matrix.runtime }}.zip
8580
asset_name: convertApi-cli-${{ matrix.runtime }}.zip
8681
asset_content_type: application/zip

0 commit comments

Comments
 (0)