Skip to content

Matrix Build and Release #57

Matrix Build and Release

Matrix Build and Release #57

Workflow file for this run

name: Build and Release
permissions: write-all
on:
push:
branches:
- main # You can change this to match your main branch name
schedule:
- cron: '0 0 * * 1' # Run every Monday at midnight UTC
workflow_dispatch:
inputs:
version:
required: true
type: string
default: "7.14"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
channel: [stable, longterm, testing, dev, custom]
exclude:
- channel: dev
- channel: longterm
steps:
- name: Checkout code
uses: actions/checkout@v2
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
- name: Install packages into building machine
run: sudo apt-get install -y unzip qemu-utils rsync gdisk dosfstools parted genisoimage
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
- name: Set version if release channel name
id: get-version
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') }}
run: |
ROS7=`curl https://download.mikrotik.com/routeros/NEWESTa7.${{matrix.channel}} | awk '{print $1}'`
echo "ROSVER=$ROS7" >> $GITHUB_ENV
- name: Set version based on manually triggered build
id: get-version-custom
if: ${{ github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' }}
run: |
echo "ROSVER=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Print versions for debugging
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
run: |
echo "Build using $ROSVER"
- name: Run script to download and modify the CHR images
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
run: sudo bash build.bash $ROSVER
- name: Upload created image files as artifacts of build
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: ./chr*
- name: Push git tag to save builder's code (required for release)
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag Build${{ github.run_id }}-${{matrix.channel}}
git push origin Build${{ github.run_id }}-${{matrix.channel}}
- name: Create GitHub release
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
id: create-release
uses: actions/create-release@v1 # comnoco/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: Build${{ github.run_id }}-${{matrix.channel}} # ${{ github.ref }}
release_name: ${{ env.ROSVER }}
body: |
UEFI-enabled CHR images, built by GitHub
`chr-${{ env.ROSVER }}.uefi-fat.raw` for VirtIO-based hypervisors
`chr-${{ env.ROSVER }}.uefi-fat.vmdk` for VMWare (with UEFI BIOS in VMX file)
Optionally, there is a chr-extra-packages disk image with the extra packages that can be mounted
*Verison:* **${{ env.ROSVER }} (${{ matrix.channel }})** [ Build ${{ github.run_id }} ]
draft: false
prerelease: true
- name: Upload CHR RAW image to release
id: upload-release-asset-raw
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./chr-${{ env.ROSVER }}.uefi-fat.raw
asset_name: chr-${{ env.ROSVER }}.uefi-fat.raw
asset_content_type: application/octet-stream
- name: Upload CHR VMDK image to release
id: upload-release-asset-vmdk
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./chr-${{ env.ROSVER }}.uefi-fat.vmdk
asset_name: chr-${{ env.ROSVER }}.uefi-fat.vmdk
asset_content_type: application/octet-stream
- name: Upload CHR extra-packages image to release (RAW)
id: upload-release-asset-extra-packages-raw
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./chr-extra-packages-${{ env.ROSVER }}.img
asset_name: extra-packages-${{ env.ROSVER }}.img
asset_content_type: application/octet-stream
- name: Upload CHR extra-packages image to release (VMDK)
id: upload-release-asset-extra-packages-vmdk
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./chr-extra-packages-${{ env.ROSVER }}.vmdk
asset_name: extra-packages-${{ env.ROSVER }}.vmdk
asset_content_type: application/octet-stream
- name: Upload CHR extra-packages image to release (ISO)
id: upload-release-asset-extra-packages-iso
if: ${{ (github.event_name != 'workflow_dispatch' && matrix.channel != 'custom') || ( github.event_name == 'workflow_dispatch' && matrix.channel == 'custom' )}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./chr-extra-packages-${{ env.ROSVER }}.iso
asset_name: extra-packages-${{ env.ROSVER }}.iso
asset_content_type: application/octet-stream