Build Addons #214
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ash | |
# | |
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
name: Build Addons | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "format %y.%-m.$i or auto" | |
required: false | |
type: string | |
prerelease: | |
description: "pre release" | |
default: false | |
type: boolean | |
clean: | |
description: "clean" | |
default: false | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Clean Old | |
if: inputs.clean == true | |
uses: Nats-ji/delete-old-releases@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
keep-count: 10 | |
keep-old-minor-releases: false | |
- name: Changelog | |
uses: Bullrich/generate-release-changelog@master | |
id: Changelog | |
env: | |
REPO: ${{ github.repository }} | |
- name: Init Env | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "AuxXxilium" | |
sudo timedatectl set-timezone "Europe/Berlin" | |
- name: Calculate Version | |
run: | | |
# Calculate Version | |
VERSION="" | |
if [ -n "${{ inputs.version }}" ]; then | |
VERSION="${{ inputs.version }}" | |
else | |
LATEST_TAG="`curl -skL "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r ".tag_name" 2>/dev/null`" | |
if [ -n "${LATEST_TAG}" -a "`echo ${LATEST_TAG} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then # format %y.%-m.$i | |
VERSION="`echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.'`" | |
else | |
VERSION="`date +'%y.%-m'`.0" | |
fi | |
fi | |
if [ -n "${VERSION}" ]; then | |
# Modify Source File | |
echo "Version: ${VERSION}" | |
echo "${VERSION}" >VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
fi | |
- name: Build Addon Packages | |
run: | | |
./compile-addons.sh | |
zip -9 addons.zip -j *.addon VERSION | |
- name: Upload to Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: addons | |
path: | | |
addons.zip | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: env.VERSION != '' | |
with: | |
tag_name: ${{ env.VERSION }} | |
prerelease: ${{ inputs.prerelease }} | |
body: | | |
${{ steps.Changelog.outputs.changelog }} | |
files: | | |
addons.zip | |
*.addon |