mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-09-07 22:36:52 +00:00
modified: .github/workflows/main.yml
This commit is contained in:
133
.github/workflows/main.yml
vendored
133
.github/workflows/main.yml
vendored
@@ -14,53 +14,104 @@ on:
|
||||
- all
|
||||
- v6
|
||||
- v7
|
||||
release:
|
||||
description: 'Release'
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
jobs:
|
||||
Patch_Stable_V7:
|
||||
if: |
|
||||
(github.event_name == 'schedule') ||
|
||||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v7'))
|
||||
uses: ./.github/workflows/patch_v7.yml
|
||||
with:
|
||||
channel: stable
|
||||
release: true
|
||||
secrets: inherit
|
||||
|
||||
Patch_LongTerm_V7:
|
||||
if: |
|
||||
(github.event_name == 'schedule') ||
|
||||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v7'))
|
||||
uses: ./.github/workflows/patch_v7.yml
|
||||
with:
|
||||
channel: long-term
|
||||
release: true
|
||||
secrets: inherit
|
||||
Check_Versions:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upgrades_v6: ${{ steps.set-matrix.outputs.upgrades_v6 }}
|
||||
upgrades_v7: ${{ steps.set-matrix.outputs.upgrades_v7 }}
|
||||
steps:
|
||||
- name: Fetch and compare versions
|
||||
id: set-matrix
|
||||
run: |
|
||||
OFFICIAL_UPGRADE=$(curl -s https://upgrade.mikrotik.com/routeros/upgrade.json || echo '{}')
|
||||
if ! echo "$OFFICIAL_UPGRADE" | jq -e . >/dev/null 2>&1; then
|
||||
OFFICIAL_UPGRADE='{}'
|
||||
fi
|
||||
|
||||
Patch_Development_V7:
|
||||
if: |
|
||||
(github.event_name == 'schedule') ||
|
||||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v7'))
|
||||
uses: ./.github/workflows/patch_v7.yml
|
||||
with:
|
||||
channel: development
|
||||
release: true
|
||||
secrets: inherit
|
||||
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
|
||||
PATCH_UPGRADE=$(curl -s https://upgrade.mikrotik.ltd/routeros/upgrade.json || echo '{}')
|
||||
if ! echo "$PATCH_UPGRADE" | jq -e . >/dev/null 2>&1; then
|
||||
PATCH_UPGRADE='{}'
|
||||
fi
|
||||
|
||||
Patch_Stable_V6:
|
||||
if: |
|
||||
(github.event_name == 'schedule') ||
|
||||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v6'))
|
||||
CANDIDATES=$(echo "$OFFICIAL_UPGRADE" | jq -c --argjson patch "$PATCH_UPGRADE" '
|
||||
($patch.upgradePaths // {}) as $paths |
|
||||
.upgradePaths // {} | to_entries | map(
|
||||
.value.version as $official_version |
|
||||
$paths[.key] as $patch_value |
|
||||
select(
|
||||
$patch_value != null and
|
||||
$official_version != $patch_value.version and
|
||||
( any( $paths[] | .version; . == $official_version ) | not ) and
|
||||
( .key | test("^NEWEST6") or .key | test("^NEWESTa7") )
|
||||
) | {
|
||||
majorVersion: (if .key | test("^NEWESTa7") then "7" else "6" end),
|
||||
channel: (.key | split(".")[1]),
|
||||
version: .value.version
|
||||
}
|
||||
)
|
||||
' || echo '[]')
|
||||
else
|
||||
CANDIDATES=$(echo "$OFFICIAL_UPGRADE" | jq -c '
|
||||
.upgradePaths // {} | to_entries | map(
|
||||
select( .key | test("^NEWEST6") or .key | test("^NEWESTa7") )
|
||||
| {
|
||||
majorVersion: (if .key | test("^NEWESTa7") then "7" else "6" end),
|
||||
channel: (.key | split(".")[1]),
|
||||
version: .value.version
|
||||
}
|
||||
)
|
||||
' || echo '[]')
|
||||
fi
|
||||
|
||||
VERSION_FILTER="${{ inputs.version || 'all' }}"
|
||||
if [[ "$VERSION_FILTER" == "v6" ]]; then
|
||||
V6_MATRIX=$(echo "$CANDIDATES" | jq -c 'map(select(.majorVersion == "6"))')
|
||||
V7_MATRIX='[]'
|
||||
elif [[ "$VERSION_FILTER" == "v7" ]]; then
|
||||
V6_MATRIX='[]'
|
||||
V7_MATRIX=$(echo "$CANDIDATES" | jq -c 'map(select(.majorVersion == "7"))')
|
||||
else
|
||||
V6_MATRIX=$(echo "$CANDIDATES" | jq -c 'map(select(.majorVersion == "6"))')
|
||||
V7_MATRIX=$(echo "$CANDIDATES" | jq -c 'map(select(.majorVersion == "7"))')
|
||||
fi
|
||||
|
||||
echo "upgrades_v6=$V6_MATRIX" >> $GITHUB_OUTPUT
|
||||
echo "upgrades_v7=$V7_MATRIX" >> $GITHUB_OUTPUT
|
||||
echo "Upgrades V6: $V6_MATRIX"
|
||||
echo "Upgrades V7: $V7_MATRIX"
|
||||
|
||||
Patch_V6:
|
||||
needs: Check_Versions
|
||||
if: ${{ needs.Check_Versions.outputs.upgrades_v6 != '[]' }}
|
||||
uses: ./.github/workflows/patch_v6.yml
|
||||
strategy:
|
||||
matrix:
|
||||
target: ${{ fromJson(needs.Check_Versions.outputs.upgrades_v6) }}
|
||||
fail-fast: false
|
||||
with:
|
||||
channel: stable
|
||||
release: true
|
||||
channel: ${{ matrix.target.channel }}
|
||||
version: ${{ matrix.target.version }}
|
||||
release: ${{ github.event_name == 'workflow_dispatch' && inputs.release || github.event_name != 'workflow_dispatch' && true }}
|
||||
secrets: inherit
|
||||
|
||||
Patch_LongTerm_V6:
|
||||
if: |
|
||||
(github.event_name == 'schedule') ||
|
||||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v6'))
|
||||
uses: ./.github/workflows/patch_v6.yml
|
||||
Patch_V7:
|
||||
needs: Check_Versions
|
||||
if: ${{ needs.Check_Versions.outputs.upgrades_v7 != '[]' }}
|
||||
uses: ./.github/workflows/patch_v7.yml
|
||||
strategy:
|
||||
matrix:
|
||||
target: ${{ fromJson(needs.Check_Versions.outputs.upgrades_v7) }}
|
||||
fail-fast: false
|
||||
with:
|
||||
channel: long-term
|
||||
release: true
|
||||
secrets: inherit
|
||||
channel: ${{ matrix.target.channel }}
|
||||
version: ${{ matrix.target.version }}
|
||||
release: ${{ github.event_name == 'workflow_dispatch' && inputs.release || github.event_name != 'workflow_dispatch' && true }}
|
||||
secrets: inherit
|
||||
Reference in New Issue
Block a user