-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Publish and Release on Commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger workflow on push to the main branch; change this as needed | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up .NET | ||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' # Use the appropriate version | ||
|
||
# Step 3: Restore dependencies | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
# Step 4: Publish the project | ||
- name: Publish the application | ||
run: dotnet publish -c Release -o ./publish # Output to ./publish folder | ||
|
||
# Step 5: Create a release | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.sha }} | ||
release_name: Release ${{ github.sha }} | ||
draft: false | ||
prerelease: false | ||
|
||
# Step 6: Upload published files to release | ||
- name: Upload .NET Publish Artifacts | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./publish | ||
asset_name: published_app.zip | ||
asset_content_type: application/zip |