2024-05-27 19:33:51 +02:00

99 lines
3.2 KiB
YAML

name: 'Build Plugin'
on:
push:
branches: [ "master" ]
paths-ignore:
- '**/README.md'
- '.github/ISSUE_TEMPLATE/**'
- 'docs/**'
- 'images/**'
- 'manifest.json'
pull_request:
branches: [ "master" ]
paths-ignore:
- '**/README.md'
- '.github/ISSUE_TEMPLATE/**'
- 'docs/**'
- 'images/**'
- 'manifest.json'
permissions:
contents: write
packages: write
jobs:
build:
if: ${{ ! startsWith(github.event.head_commit.message, 'v0.') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Embed version info
run: echo "${{ github.sha }}" > ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt
- name: Retrieve commit identification
run: |
GIT_HASH=$(git rev-parse --short HEAD)
echo "GIT_HASH=${GIT_HASH}" >> $GITHUB_ENV
- name: Build
run: dotnet build --no-restore
- name: Upload artifact
uses: actions/upload-artifact@v4.3.3
if: github.event_name != 'pull_request'
with:
name: ConfusedPolarBear.Plugin.IntroSkipper-${{ env.GIT_HASH }}.dll
path: ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll
if-no-files-found: error
- name: Upload artifact
uses: actions/upload-artifact@v4.3.3
if: github.event_name == 'pull_request'
with:
name: ConfusedPolarBear.Plugin.IntroSkipper-${{ github.head_ref }}.dll
path: ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll
retention-days: 7
if-no-files-found: error
- name: Create archive
if: github.event_name != 'pull_request'
run: zip -j "intro-skipper-${{ env.GIT_HASH }}.zip" ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll
- name: Generate md5
if: github.event_name != 'pull_request'
run: |
md5sum intro-skipper-${{ env.GIT_HASH }}.zip > intro-skipper-${{ env.GIT_HASH }}.md5
checksum="$(awk '{print $1}' intro-skipper-${{ env.GIT_HASH }}.md5)"
echo "CHECKSUM=$checksum" >> $GITHUB_ENV
- name: Check if prerelease with tag '10.9/preview' exists and delete it
if: github.event_name != 'pull_request'
run: |
if gh release view 10.9/preview --json id 2>/dev/null; then
release_id=$(gh release view 10.9/preview --json id -q ".id")
echo "Deleting existing prerelease with id: $release_id"
gh release delete 10.9/preview -y
else
echo "No existing prerelease with tag '10.9/preview' found."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new prerelease with tag '10.9/preview'
if: github.event_name != 'pull_request'
run: gh release create 10.9/preview "intro-skipper-${{ env.GIT_HASH }}.zip" --prerelease --title "intro-skipper-${{ env.GIT_HASH }}" --notes "This is a prerelease version."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}