refactor(ci): refactor version handling #523
Workflow file for this run
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
name: Build MainsailOS | |
on: | |
push: | |
branches: | |
- "develop" | |
paths: | |
- "src/modules/**" | |
- "src/build_dist" | |
- "config/**" | |
- ".github/workflows/BuildImages.yml" | |
- ".github/workflow_config.yml" | |
- ".github/scripts/setup_matrix.py" | |
tags-ignore: | |
- "**" | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
paths: | |
- "src/**" | |
- "config/**" | |
- ".github/workflows/BuildImages.yml" | |
- ".github/scripts/setup_matrix.py" | |
- ".github/workflow_config.yml" | |
workflow_dispatch: | |
# Allow to stop obsolete workflows | |
concurrency: | |
group: ci-buildtrain-${{ github.ref }}-1 | |
cancel-in-progress: true | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create Matrix | |
id: set-matrix | |
run: | | |
PY_INT=$(command -v python3) | |
CONFIG="${{ github.workspace }}/.github/workflow_config.yml" | |
GROUP="buildtest" | |
$PY_INT ${{ github.workspace }}/.github/scripts/setup_matrix.py -c $CONFIG -g $GROUP --git | |
build: | |
needs: setup | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
config: ${{ fromJson(needs.setup.outputs.matrix) }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: repository | |
submodules: true | |
- name: Build image | |
id: build | |
uses: ./repository/.github/actions/build | |
with: | |
config: ${{ matrix.config }} | |
- name: Upload failed Logfile | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: failed-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}.log | |
path: repository/src/build.log | |
- name: Rename image file | |
id: move-image | |
if: success() | |
shell: bash | |
run: | | |
source repository/src/config | |
NOW="$(date +"%Y-%m-%d")" | |
IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" | |
mv repository/src/workspace/*.img $IMAGE.img | |
echo "image=${IMAGE}" >> $GITHUB_OUTPUT | |
- name: Compressing Image | |
shell: bash | |
run: | | |
CPU_COUNT="$(nproc)" | |
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" | |
xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img || true | |
- name: Calculating checksums | |
shell: bash | |
run: | | |
sha256sum ${{ steps.move-image.outputs.image }}.img > ${{ steps.move-image.outputs.image }}.img.sha256 | |
sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256 | |
- name: Upload Compressed Image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.move-image.outputs.image }}.img.xz | |
path: ${{ steps.move-image.outputs.image }}.img.xz | |
- name: Upload Compressed Image Checksum | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.move-image.outputs.image }}.img.xz.sha256 | |
path: ${{ steps.move-image.outputs.image }}.img.xz.sha256 | |
- name: Upload Image Checksum | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.move-image.outputs.image }}.img.sha256 | |
path: ${{ steps.move-image.outputs.image }}.img.sha256 |