This commit is contained in:
parent
8c64d9261c
commit
75f6a9f756
1 changed files with 333 additions and 60 deletions
60
.forgejo/workflows/release.yml
Normal file
60
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['*']
|
||||
|
||||
enable-openid-connect: true
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: publish
|
||||
runs-on: debian-latest
|
||||
container: mcr.microsoft.com/dotnet/sdk:10.0@sha256:0d99ebf1ccad15037b5c98c9fe8979d6b8dbac23812feae2277a0b277b5c5ffa
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: https://code.geekeey.de/actions/checkout@54953ce9d6c7d0a9cbd89d185c5b2c7515358c5f # 1
|
||||
|
||||
- name: version
|
||||
id: version
|
||||
uses: ./.forgejo/actions/version
|
||||
|
||||
- name: dotnet pack
|
||||
run: dotnet pack arcade.slnx -p:Version=${{ steps.version.outputs.version }}
|
||||
|
||||
- name: upload packages
|
||||
uses: https://code.geekeey.de/actions/artifacts/push@ae8d20e174a8706675e6d54ebd3719a2802ea9dd # 1
|
||||
with:
|
||||
name: nuget-packages
|
||||
path: artifacts/package/release
|
||||
pattern: |
|
||||
*.nupkg
|
||||
*.snupkg
|
||||
|
||||
- name: publish to nuget
|
||||
shell: bash
|
||||
env:
|
||||
AUDIENCE: "u:1:49f9431c-8baf-4432-8254-72fd1b00b8f9"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" || -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ]]; then
|
||||
echo "::error::OpenID Connect is not enabled. Set enable-openid-connect: true on the workflow or job."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
response=$(curl --fail --silent --show-error \
|
||||
--header "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${AUDIENCE}")
|
||||
token=$(printf '%s' "${response}" | grep --only-matching '"value":"[^"]*"' | cut --delimiter '"' --fields 4)
|
||||
|
||||
if [[ -z "${token}" ]]; then
|
||||
echo "::error::Failed to obtain an OpenID Connect token from Forgejo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "::add-mask::${token}"
|
||||
|
||||
feed="${{ forgejo.server_url }}/api/packages/${{ forgejo.repository_owner }}/nuget/index.json"
|
||||
|
||||
dotnet nuget add source --name forgejo --username forgejo-publish --password "$token" --store-password-in-clear-text "$feed"
|
||||
dotnet nuget push "artifacts/package/release/*.nupkg" "artifacts/package/release/*.snupkg" --source forgejo --skip-duplicate
|
||||
Loading…
Reference in a new issue