Build addons #122
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
# | |
# Copyright (C) 2022 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 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
repository: RROrg/rr-addons | |
token: ${{ secrets.RRORG }} | |
path: rr-addons | |
- name: Init Env | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
- name: Calculate version | |
run: | | |
# Calculate version | |
VERSION="" | |
if [ -n "${{ inputs.version }}" ]; then | |
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then | |
VERSION="${{ inputs.version }}" | |
else | |
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/rr-addons/releases" | jq -r ".[0].tag_name" 2>/dev/null)" | |
if [ -n "${LATEST_TAG}" ] && [ "$(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 | |
else | |
VERSION="" | |
fi | |
echo "VERSION: ${VERSION}" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Build addon packages | |
run: | | |
VERSION="${{ env.VERSION }}" | |
VERSION="${VERSION:-"test"}" | |
cd rr-addons | |
sed -i "s/version:.*$/version: ${VERSION}/g" */manifest.yml | |
. ./compile.sh | |
echo "${VERSION}" > "VERSION" | |
zip -9 ${{ github.workspace }}/addons-${VERSION}.zip -j *.addon VERSION | |
- name: Upload to Artifacts | |
if: success() && env.VERSION == '' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: addons | |
path: | | |
addons*.zip | |
retention-days: 5 | |
- name: Release | |
uses: ncipollo/release-action@v1 | |
if: success() && env.VERSION != '' | |
with: | |
tag: ${{ env.VERSION }} | |
prerelease: ${{ inputs.prerelease }} | |
artifacts: addons*.zip | |
owner: RROrg | |
repo: rr-addons | |
token: ${{ secrets.RRORG }} |