66 lines
2.4 KiB
YAML
Raw Permalink Normal View History

2024-11-27 12:07:20 -08:00
name: Upload Python Package
permissions:
contents: write
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
- name: Generate Changelog
run: .gitea/release_message.sh > release_message.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: release_message.md
deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
2024-11-27 22:33:49 +01:00
- name: Set up dotnet
uses: actions/setup-dotnet@v4
2024-11-27 12:07:20 -08:00
with:
2024-11-27 22:33:49 +01:00
dotnet-version: '9.0.X'
2024-11-27 12:07:20 -08:00
- name: Check version match
run: |
2024-11-27 22:45:11 +01:00
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $2}' | tr '-' '_')
2024-11-27 23:10:43 +01:00
if [ "$(cat DotnetTestLib/VERSION)" = "${GITHUB_REF_NAME}" ] ; then
2024-11-27 12:07:20 -08:00
echo "Version matches successfully!"
else
echo "Version must match!"
exit -1
fi
- name: Build and publish
env:
2024-11-28 01:29:55 -08:00
GITEA_PAT: ${{ secrets.PACKAGE_GITEA_PAT }}
2024-11-27 12:07:20 -08:00
run: |
REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $1}')
2024-11-27 23:18:49 +01:00
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $2}' | tr '-' '_')
2024-11-28 00:52:31 -08:00
REPOSITORY_SOURCE_NAME=gitea-repo
2024-11-28 00:39:55 -08:00
if [ -z "$(dotnet nuget config get all | grep "/packages/${REPOSITORY_OWNER}/nuget/index.json")" ]; then
2024-11-28 01:29:55 -08:00
dotnet nuget add source --name $REPOSITORY_SOURCE_NAME https://git.disi.dev/api/packages/$REPOSITORY_OWNER/nuget/index.json
2024-11-28 00:52:31 -08:00
else
QUOTED_REPOSITORY_SOURCE_NAME=$(dotnet nuget config get all | grep "/packages/${REPOSITORY_OWNER}/nuget/index.json" | awk '{print $2}' | awk -F= '{print $2}')
REPOSITORY_SOURCE_NAME=${QUOTED_REPOSITORY_SOURCE_NAME:1:-1}
2024-11-27 23:27:53 +01:00
fi
2024-11-27 20:09:05 +00:00
dotnet pack --include-symbols --include-source -p:PackageVersion=$(cat $REPOSITORY_NAME/VERSION) DotnetTestLib.sln
2024-11-28 01:29:55 -08:00
dotnet nuget push -k $GITEA_PAT --source $REPOSITORY_SOURCE_NAME $REPOSITORY_NAME/bin/Release/$REPOSITORY_NAME.$(cat $REPOSITORY_NAME/VERSION).symbols.nupkg