Update CI to accommodate custom version bumps

This commit is contained in:
TrainDoctor
2022-09-04 20:00:53 -07:00
parent 5f469bfb16
commit d2da85460d
4 changed files with 99 additions and 20 deletions

View File

@@ -15,6 +15,15 @@ on:
- none - none
- prerelease - prerelease
- release - release
bump:
type: choice
description: Semver to bump
default: 'none'
options:
- none
- patch
- minor
- major
permissions: permissions:
contents: write contents: write
@@ -66,29 +75,90 @@ jobs:
with: with:
path: ./dist/PluginLoader path: ./dist/PluginLoader
# release:
# name: Release the package
# if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'release' }}
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Checkout 🧰
# uses: actions/checkout@v3
# - name: Fetch package artifact ⬇️
# uses: actions/download-artifact@v3
# with:
# name: PluginLoader
# path: dist
# - name: Release 📦
# uses: softprops/action-gh-release@v1
# if: ${{ !env.ACT }}
# with:
# name: Release ${{ steps.tag_version.outputs.new_tag }}
# tag_name: ${{ steps.tag_version.outputs.new_tag }}
# files: ./dist/PluginLoader
# generate_release_notes: true
release: release:
name: Release the package name: Release stable version of the package
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'release' }} if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'release' }}
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🧰 - name: Install semver-tool asdf
uses: actions/checkout@v3 uses: asdf-vm/actions/install@v1
with:
tool_versions: |
semver 3.3.0
- name: Fetch package artifact ⬇️ - name: Fetch package artifact ⬇️
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
if: ${{ !env.ACT }}
with: with:
name: PluginLoader name: PluginLoader
path: dist path: dist
- name: Get latest release
uses: rez0n/actions-github-release@main
id: latest_release
env:
token: ${{ secrets.GITHUB_TOKEN }}
# repository: "SteamDeckHomebrew/decky-loader"
repository: "TrainDoctor/decky-loader"
type: "nodraft"
- name: Prepare tag ⚙️
id: ready_tag
run: |
export VERSION=${{ steps.latest_release.outputs.release }}
echo "VERS: $VERSION"
if [[ "$VERSION" =~ "-pre" ]]; then
OUT=$(semver bump release "$VERSION")
elif [[ ! "$VERSION" =~ "-pre" ]]; then
if [[ "${{github.event.inputs.bump}}" != "none" ]]; then
OUT=$(semver bump ${{github.event.inputs.bump}} "$VERSION")
fi
fi
echo "OUT: v$OUT"
echo ::set-output name=tag_name::v$OUT
- name: Push tag 📤
uses: rickstaa/action-create-tag@v1.3.2
if: ${{ steps.ready_tag.outputs.tag_name && github.event_name == 'workflow_dispatch' && !env.ACT }}
with:
tag: ${{ steps.ready_tag.outputs.tag_name }}
message: Pre-release ${{ steps.ready_tag.outputs.tag_name }}
- name: Release 📦 - name: Release 📦
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: ${{ !env.ACT }} if: ${{ github.event_name == 'workflow_dispatch' && !env.ACT }}
with: with:
name: Release ${{ steps.tag_version.outputs.new_tag }} name: Prerelease ${{ steps.ready_tag.outputs.tag_name }}
tag_name: ${{ steps.tag_version.outputs.new_tag }} tag_name: ${{ steps.ready_tag.outputs.tag_name }}
files: ./dist/PluginLoader files: ./dist/PluginLoader
prerelease: false
generate_release_notes: true generate_release_notes: true
prerelease: prerelease:
@@ -104,30 +174,36 @@ jobs:
tool_versions: | tool_versions: |
semver 3.3.0 semver 3.3.0
- name: Checkout 🧰
uses: actions/checkout@v3
- name: Fetch package artifact ⬇️ - name: Fetch package artifact ⬇️
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
if: ${{ !env.ACT }}
with: with:
name: PluginLoader name: PluginLoader
path: dist path: dist
- name: Get tag 🏷️ - name: Get latest release
id: old_tag uses: rez0n/actions-github-release@main
uses: rafarlopes/get-latest-pre-release-tag-action@v1 id: latest_release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
with: repository: "SteamDeckHomebrew/decky-loader"
repository: 'decky-loader' type: "nodraft"
- name: Prepare tag ⚙️ - name: Prepare tag ⚙️
id: ready_tag id: ready_tag
run: | run: |
export VERSION=${{ steps.old_tag.outputs.tag }} export VERSION=${{ steps.latest_release.outputs.release }}
echo "VERS: $VERSION" echo "VERS: $VERSION"
OUT=$(semver bump prerel "$VERSION") if [[ ! "$VERSION" =~ "-pre" ]]; then
echo "OUT: $OUT" OUT=$(semver bump minor "$VERSION")
OUT="$OUT-pre"
elif [[ "$VERSION" =~ "-pre" ]]; then
if [[ "${{github.event.inputs.bump}}" != "none" ]]; then
OUT=$(semver bump ${{github.event.inputs.bump}} "$OUT")
fi
fi
OUT=$(semver bump prerel "$OUT")
echo "OUT: v$OUT"
echo ::set-output name=tag_name::v$OUT echo ::set-output name=tag_name::v$OUT
- name: Push tag 📤 - name: Push tag 📤

View File

@@ -1,5 +1,6 @@
{ {
"inputs": { "inputs": {
"release": "prerelease" "release": "prerelease",
"bump": "none"
} }
} }

View File

@@ -1,5 +1,6 @@
{ {
"inputs": { "inputs": {
"release": "release" "release": "release",
"bump": "none"
} }
} }

View File

@@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
type=$1 type=$1
# bump=$2
oldartifactsdir="old" oldartifactsdir="old"