Skip to content

Commit 2d0cb1f

Browse files
committed
Refactoring release workflow actions
#3
1 parent f394a28 commit 2d0cb1f

File tree

1 file changed

+77
-56
lines changed

1 file changed

+77
-56
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,102 @@
1-
name: Build, create, and release
1+
name: Release plugin
22

3-
on:
3+
on:
44
workflow_dispatch:
55
inputs:
66
rel_version:
77
description: 'Release version (examples: 1.9.0-rc.1, 1.9.1)'
8-
required: true
8+
required: true
99
type: string
1010

11+
env:
12+
DOTNET_VERSION: '9.0.x'
13+
ARTIFACT_DIR: ./release
14+
PUBLISH_DIR: ${{ github.workspace }}/publish
15+
DIST_DIR: ${{ github.workspace }}/dist
16+
DOWNLOAD_DIR: ./downloaded-artifacts
17+
1118
jobs:
1219
build:
13-
runs-on: ubuntu-latest
14-
env:
15-
ARTIFACT_DIR: ./release
20+
runs-on: ubuntu-latest
21+
1622
steps:
17-
- uses: actions/checkout@v2
18-
with:
19-
fetch-depth: 0 #fetch-depth is needed for GitVersion
20-
21-
- name: Create Branch
22-
uses: peterjgrainger/action-create-branch@v2.2.0
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
25-
with:
26-
branch: 'release-${{ inputs.rel_version }}'
27-
sha: '${{ github.event.pull_request.head.sha }}'
28-
29-
- name: Setup .NET
30-
uses: actions/setup-dotnet@v3.2.0
31-
with:
32-
dotnet-version: 9.0.x
33-
34-
- name: Restore dependencies
35-
run: dotnet restore
36-
37-
- name: Build
38-
run: dotnet build --configuration Release /p:Version='${{ inputs.rel_version }}' --no-restore
39-
40-
- name: Test
41-
run: dotnet test --configuration Release /p:Version='${{ inputs.rel_version }}' --no-build
42-
43-
- name: Publish project
44-
run: dotnet publish src/FlowSynx.Plugins.Azure.Blobs.csproj -c Release -o "${{github.workspace}}/publish"
45-
46-
- name: Zip the output files
47-
run: |
48-
mkdir -p "${{github.workspace}}/dist"
49-
cd "${{github.workspace}}/publish"
50-
7z a -tzip "${{github.workspace}}/dist/release-${{ inputs.rel_version }}.zip" *
51-
52-
- name: Upload artifacts
53-
uses: actions/upload-artifact@v4
54-
with:
55-
name: uploaded-artifacts
56-
path: "${{github.workspace}}/dist"
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v3.2.0
30+
with:
31+
dotnet-version: ${{ env.DOTNET_VERSION }}
32+
33+
- name: Restore dependencies
34+
run: dotnet restore
35+
36+
- name: Build solution
37+
run: dotnet build --configuration Release /p:Version='${{ inputs.rel_version }}' --no-restore
38+
39+
- name: Run tests
40+
run: dotnet test --configuration Release /p:Version='${{ inputs.rel_version }}' --no-build
41+
42+
- name: Publish project
43+
run: dotnet publish src/FlowSynx.Plugins.Azure.Blobs.csproj -c Release -o "${{ env.PUBLISH_DIR }}"
44+
45+
- name: Package release artifacts
46+
run: |
47+
mkdir -p "${{ env.DIST_DIR }}"
48+
cd "${{ env.PUBLISH_DIR }}"
49+
7z a -tzip "${{ env.DIST_DIR }}/release-${{ inputs.rel_version }}.zip" *
50+
51+
- name: Upload release artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: uploaded-artifacts
55+
path: ${{ env.DIST_DIR }}
5756

5857
release:
5958
runs-on: ubuntu-latest
6059
needs: build
61-
if: github.ref == 'refs/heads/master' # only run job if on the master branch
62-
env:
63-
ARTIFACT_DIR: ./downloaded-artifacts
60+
if: github.ref == 'refs/heads/master'
61+
6462
steps:
65-
- name: Download artifacts
63+
- name: Download release artifacts
6664
uses: actions/download-artifact@v4
6765
with:
6866
name: uploaded-artifacts
69-
path: ${{ env.ARTIFACT_DIR }}
67+
path: ${{ env.DOWNLOAD_DIR }}
68+
69+
- name: Generate SHA256 checksums
70+
run: |
71+
cd "${{ env.DOWNLOAD_DIR }}"
72+
for file in *; do sha256sum -b "$file" > "$file.sha256"; done
73+
cd -
7074
71-
- name: generate checksum files
72-
run: cd ${ARTIFACT_DIR} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd -
73-
7475
- name: Create GitHub Release
7576
uses: ncipollo/release-action@v1
7677
with:
7778
tag: v${{ inputs.rel_version }}
7879
name: Azure Blobs Plugin v${{ inputs.rel_version }}
79-
artifacts: "**/*.*"
80-
body: "This is the v${{ inputs.rel_version }} release of Azure Blobs Plugin for FlowSynx System."
80+
artifacts: "${{ env.DOWNLOAD_DIR }}/**/*.*"
81+
body: |
82+
This is the v${{ inputs.rel_version }} release of Azure Blobs Plugin for FlowSynx System.
8183
token: ${{ secrets.GH_TOKEN }}
84+
85+
create-branch:
86+
runs-on: ubuntu-latest
87+
needs: [build, release]
88+
if: github.ref == 'refs/heads/master'
89+
90+
steps:
91+
- name: Checkout repository
92+
uses: actions/checkout@v2
93+
with:
94+
fetch-depth: 0
95+
96+
- name: Create release branch
97+
uses: peterjgrainger/action-create-branch@v2.2.0
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
100+
with:
101+
branch: release-${{ inputs.rel_version }}
102+
sha: ${{ github.sha }}

0 commit comments

Comments
 (0)