Skip to content

Commit

Permalink
Added new build and publish workflows (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-fernandez-rodriguez authored Dec 13, 2024
1 parent b8479de commit 729c708
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 5 deletions.
53 changes: 48 additions & 5 deletions .github/workflows/registerly-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Build Registerly
concurrency: Registerly

on:
push:
Expand All @@ -12,21 +10,66 @@ on:
paths: [ "Registerly/**" ]
workflow_dispatch:

env:
PROJECT: Registerly

jobs:
build:

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Get version
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
id: get-version
uses: kzrnm/get-net-sdk-project-versions-action@v2
with:
proj-path: ./${{ env.PROJECT }}/src/DeviantCoding.${{ env.PROJECT }}.csproj
- name: Check version is valid
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.PROJECT }}-${{ steps.get-version.outputs.version }}
title: ${{ env.PROJECT }} v${{ steps.get-version.outputs.version }}
prerelease: ${{ steps.get-version.outputs.version-suffix != '' && '--prerelease' || '' }}
run: |
PUBLISHED_RELEASE_NAME="$(gh release list --json name,tagName,isDraft --jq '.[] | select(.tagName=="${{ env.tag }}" and .isDraft==false)|.name')"
if [ -n "${PUBLISHED_RELEASE_NAME}" ]
then
echo "Error! There is already a published release with version ${{ env.tag }}"
exit 1
fi
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: |
chmod +x ./Registerly/build.sh
cd ./Registerly/
chmod +x ./${{ env.PROJECT }}/build.sh
cd ./${{ env.PROJECT }}/
./build.sh
shell: bash
- name: Create or update release
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.PROJECT }}-${{ steps.get-version.outputs.version }}
title: ${{ env.PROJECT }} v${{ steps.get-version.outputs.version }}
prerelease: ${{ steps.get-version.outputs.version-suffix != '' && '--prerelease' || '' }}
run: |
DRAFT_RELEASE_NAME="$(gh release list --json name,tagName,isDraft --jq '.[] | select(.tagName=="${{ env.tag }}" and .isDraft)|.name')"
if [ -z "${DRAFT_RELEASE_NAME}" ]
then
gh release create "$tag" ./${{ env.PROJECT }}/src/bin/Release/*.nupkg --draft ${prerelease:+"$prerelease"} --title "$title" --target ${{ github.sha }}
else
echo "Updating existing release $tag"
gh release upload "$tag" ./${{ env.PROJECT }}/src/bin/Release/*.nupkg --clobber
gh release edit "$tag" --target ${{ github.sha }}
fi
shell: bash


25 changes: 25 additions & 0 deletions .github/workflows/registerly-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Registerly
concurrency: Registerly

on:
release:
types: [published]

env:
PROJECT: Registerly

jobs:
deployment:
runs-on: ubuntu-latest
environment: NUGETTEST.ORG
steps:
- name: Get package
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository_owner }}/${{ github.event.repository.name }}
tag: ${{ github.ref_name }}
run: |
gh release download "${{ env.tag }}"
shell: bash
- name: Publish to nuget.org
run: dotnet nuget push ./*.nupkg --api-key ${{ secrets.NUGETORG_APIKEY }} --source ${{ vars.NUGETORG_URL }}

0 comments on commit 729c708

Please sign in to comment.