104 lines
3.8 KiB
YAML
Raw Normal View History

2022-06-10 16:14:09 -05:00
name: 'Build Plugin'
2022-06-10 16:19:07 -05:00
on:
push:
2024-04-09 22:08:39 -04:00
branches: [ "master" ]
2024-04-19 21:41:03 -04:00
paths-ignore:
- '**/README.md'
- '.github/ISSUE_TEMPLATE/**'
- 'docs/**'
- 'images/**'
- 'manifest.json'
2022-06-10 16:19:07 -05:00
pull_request:
2024-04-09 22:08:39 -04:00
branches: [ "master" ]
2024-04-19 21:41:03 -04:00
paths-ignore:
- '**/README.md'
- '.github/ISSUE_TEMPLATE/**'
- 'docs/**'
- 'images/**'
- 'manifest.json'
2022-06-10 16:19:07 -05:00
2024-03-01 11:40:05 -05:00
permissions:
contents: write
2024-03-29 20:40:49 +01:00
packages: write
2024-03-01 11:40:05 -05:00
2022-06-10 16:19:07 -05:00
jobs:
build:
2024-04-10 07:26:03 -04:00
if: ${{ ! startsWith(github.event.head_commit.message, 'v0.') }}
2022-06-10 16:19:07 -05:00
runs-on: ubuntu-latest
steps:
2024-09-19 11:20:28 +00:00
- name: Sanitize head_ref
run: |
# Get the branch name and sanitize it
SANITIZED_BRANCH_NAME=$(echo "${{ github.head_ref }}" | sed 's/[^a-zA-Z0-9.-]/_/g')
# Export it as an environment variable
echo "SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV
- uses: actions/checkout@v4
2022-06-10 16:25:44 -05:00
2022-06-10 16:19:07 -05:00
- name: Setup .NET
uses: actions/setup-dotnet@v4
2022-06-10 16:19:07 -05:00
with:
2024-03-22 23:41:58 +01:00
dotnet-version: 8.0.x
2024-05-16 05:46:23 -04:00
- name: Setup Node.js
uses: actions/setup-node@v4
with:
2024-10-06 13:25:05 +02:00
node-version: 'lts/*'
- name: Install html-minifier-terser
run: npm install terser html-minifier-terser
- name: Minify HTML
run: |
npx html-minifier-terser --collapse-boolean-attributes --collapse-whitespace --collapse-inline-tag-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true -o ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html
npx terser ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js -o ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js -c -m
npx terser ConfusedPolarBear.Plugin.IntroSkipper/Configuration/visualizer.js -o ConfusedPolarBear.Plugin.IntroSkipper/Configuration/visualizer.js -c -m
2022-06-10 16:19:07 -05:00
- name: Restore dependencies
2024-05-11 20:11:25 +00:00
run: dotnet restore
2022-06-10 16:25:44 -05:00
2022-06-12 16:57:15 -05:00
- name: Embed version info
2024-09-21 18:42:55 +02:00
run: |
GITHUB_SHA=${{ github.sha }}
sed -i "s/string\.Empty/\"$GITHUB_SHA\"/g" ConfusedPolarBear.Plugin.IntroSkipper/Helper/Commit.cs
2022-06-12 16:57:15 -05:00
2024-03-01 11:40:05 -05:00
- name: Retrieve commit identification
run: |
GIT_HASH=$(git rev-parse --short HEAD)
echo "GIT_HASH=${GIT_HASH}" >> $GITHUB_ENV
2022-06-10 16:19:07 -05:00
- name: Build
run: dotnet build --no-restore
2022-06-10 23:08:27 -05:00
2024-07-23 21:35:42 +02:00
- name: Upload artifact
uses: actions/upload-artifact@v4.3.6
2024-07-23 21:35:42 +02:00
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.6
2024-07-23 21:35:42 +02:00
if: github.event_name == 'pull_request'
with:
2024-09-19 11:20:28 +00:00
name: ConfusedPolarBear.Plugin.IntroSkipper-${{ env.SANITIZED_BRANCH_NAME }}.dll
2024-07-23 21:35:42 +02:00
path: ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net8.0/ConfusedPolarBear.Plugin.IntroSkipper.dll
retention-days: 7
if-no-files-found: error
2024-05-16 05:46:23 -04:00
2024-03-01 11:40:05 -05:00
- name: Create archive
2024-03-02 21:05:57 -05:00
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
2024-03-01 11:40:05 -05:00
- name: Create/replace the preview release and upload artifacts
2024-03-01 11:40:05 -05:00
if: github.event_name != 'pull_request'
run: |
gh release delete '10.9/preview' --cleanup-tag --yes || true
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 }}