Files
ps-module-logging/.gitea/workflows/Publish Module.yaml

91 lines
3.4 KiB
YAML

name: Publish Powershell Module to Gitea Repository
run-name: ${{ gitea.actor }} is publishing module ${{ gitea.repository }} to Gitea
on:
push:
tags:
- '*.*.*'
workflow_dispatch:
jobs:
deploy:
needs: test
runs-on: ubuntu-22.04
container:
image: catthehacker/ubuntu:pwsh-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Register Gitea Repository
shell: pwsh
run: |
$creds = New-Object System.Management.Automation.PSCredential('actions', ('{{ secrets.PACKAGES_TOKEN }}' | ConvertTo-SecureString -AsPlainText -Force))
try {
Register-PSRepository -Name 'GiteaPublic' `
-SourceLocation 'https://gitea.norwichct.tech/api/packages/public/nuget' `
-PublishLocation 'https://gitea.norwichct.tech/api/packages/public/nuget' `
-installationPolicy Trusted `
-Credential $creds
}
catch {
Write-Host "Failed to register Gitea repository"
Write-Host $_.Exception.Message
}
finally {
Write-Host "Gitea repository registered"
}
- name: Install DotNet
run: |
echo "Installing DotNet"
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS --install-dir /usr/share/dotnet
echo Adding DotNet to PATH
export DOTNET_ROOT=/usr/share/dotnet
export PATH=$PATH:/usr/share/dotnet
- name: Publish module to Gitea
shell: pwsh
run: |
Write-Host "Adding DotNet to PATH"
$env:DOTNET_ROOT = '/usr/share/dotnet'
$env:PATH = $env:PATH + ':/usr/share/dotnet'
Write-Host "Changing to repository directory: ${{ github.workspace }}"
Set-Location -Path ${{ github.workspace }}
$moduleVersion = git describe --tags
Write-Host "Module version: $moduleVersion"
$module = get-childItem -path . -Directory -Exclude (".*", "Tests") | Select-Object -ExpandProperty Name
Write-Host "Publishing module $module to Gitea"
Publish-Module -Path $module -Repository 'GiteaPublic' -NuGetApiKey "${{ secrets.PACKAGES_TOKEN }}"
Write-Host "Module $module published to Gitea"
- name: Create draft release
uses: akkuman/gitea-release-action@v1
with:
token: ${{ secrets.GITEA_TOKEN }}
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: |
This release includes the nuget package for the ${{ github.ref_name }} version of the module.
draft: true
prerelease: ${{ contains(github.ref_name, 'rc') }}
- name: Upload release asset
uses: akkuman/gitea-release-action@v1
with:
token: ${{ secrets.GITEA_TOKEN }}
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
file: ${{ github.workspace }}/*.nupkg
draft: true
prerelease: ${{ contains(github.ref_name, 'rc') }}
- name: Publish release
uses: akkuman/gitea-release-action@v1
with:
token: ${{ secrets.GITEA_TOKEN }}
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, 'rc') }}