Skip to content

Commit

Permalink
add ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
weslleymurdock committed Jun 13, 2024
1 parent e20c3ac commit 0245242
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Continuous Delivery

on:
push:
tags:
'*'
permissions:
contents: read

env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry
jobs:
build:
runs-on: ubuntu-latest
name: Build
permissions:
contents: write

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
- name: Restore Dependencies
run: |
dotnet restore src/Input.Joystick/Input.Joystick.csproj
- name: Build
run: dotnet publish src/Input.Joystick/Input.Joystick.csproj -c Release --no-restore

- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV

- name: Pack
run: dotnet pack src/Input.Joystick/Input.Joystick.csproj -version "${VERSION}"

- name: Push to nuget
run: dotnet nuget push Input.Joystick.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${API_KEY} --skip-duplicate
env:
API_KEY: ${{ secrets.API_KEY }}

- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get Name of Artifact
run: |
ARTIFACT_PATHNAME=$(ls *.nupkg | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
- name: upload .nupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_PATHNAME }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/zip
40 changes: 40 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Continuous Integration

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry
jobs:
build:
runs-on: ubuntu-latest
name: Build
permissions:
contents: write

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
- name: Restore Dependencies
run: dotnet restore src/Input.Joystick/Input.Joystick.csproj

- name: Build
run: dotnet build src/Input.Joystick/Input.Joystick.csproj -c Release --no-restore


0 comments on commit 0245242

Please sign in to comment.