Skip to content

add ci/cd

add ci/cd #4

Workflow file for this run

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