Skip to content

ci: useactions/download-artifact@v4 (#3) #10

ci: useactions/download-artifact@v4 (#3)

ci: useactions/download-artifact@v4 (#3) #10

Workflow file for this run

name: build
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
VERSION_MAJOR: 0
VERSION_MINOR: 1
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
build: ${{ steps.version.outputs.build }}
revision: ${{ steps.version.outputs.revision }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: generate version
id: version
shell: bash
run: |
BUILD_NUMBER=0
REVISION=${{ github.run_number }}
VERSION="${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${BUILD_NUMBER}.${REVISION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "build=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
echo "revision=${REVISION}" >> $GITHUB_OUTPUT
echo "Generated version: ${VERSION}"
echo " - Build: ${BUILD_NUMBER}"
echo " - Revision (Run Number): ${REVISION}"
build:
needs: version
strategy:
matrix:
include:
- os: windows-latest
platform: windows
- os: ubuntu-latest
platform: linux
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: build (Linux)
if: runner.os == 'Linux'
run: |
echo "[+] build linux"
dotnet publish -r linux-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
- name: build (Windows)
if: runner.os == 'Windows'
run: |
echo "[+] build windows"
dotnet publish -r win-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
- name: collect artifacts
shell: bash
run: |
mkdir -p artifacts
cp build/* artifacts/
ls -lh artifacts
- name: upload artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
name: ${{ matrix.platform }}-v${{ needs.version.outputs.version }}
path: artifacts/*.*
release:
needs: [ version , build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: create release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.version.outputs.version }}
name: release v${{ needs.version.outputs.version }}
generate_releases: true
draft: false
prerelease: true
files: artifacts/*.*
- name: publish to NuGet
continue-on-error: true
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: |
echo "[+] Publishing NuGet packages with version ${{ needs.version.outputs.version }}"
shopt -s globstar nullglob
for pkg in artifacts/**/*.nupkg; do
if [[ "$pkg" == *.snupkg ]]; then
continue
fi
echo "-> dotnet nuget push $pkg"
dotnet nuget push "$pkg" \
--api-key "$NUGET_AUTH_TOKEN" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
done