From 18131355451274038c910bed7be42f3b5832c098 Mon Sep 17 00:00:00 2001 From: Joonas Onatsu Date: Thu, 12 Dec 2024 14:52:31 +0200 Subject: [PATCH] build action test --- .github/actions/build-action/action.yml | 9 ++- .github/workflows/build.yml | 82 ++++++++++++++++++------- hardware/fmo-os-rugged-devices.nix | 9 ++- 3 files changed, 70 insertions(+), 30 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 8ef4e2f..b62dc52 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -6,24 +6,23 @@ name: 'Build FMO-OS image' description: 'Build an FMO-OS image' inputs: - build_target: + BUILD_TARGET: description: 'Build target name' required: true CACHIX_TOKEN: - description: 'cachix binary cache token' + description: 'Cachix binary cache token' required: true RA_TOKEN: description: 'RA deployment token' required: true outputs: outimg: - description: 'Result image path in workdir' + description: 'Resulting output image path in workdir' runs: using: 'docker' image: 'Dockerfile' args: - - ${{ inputs.build_target }} + - ${{ inputs.BUILD_TARGET }} - ${{ inputs.CACHIX_TOKEN }} - ${{ inputs.RA_TOKEN }} - diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 707f005..d669e7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,8 +6,11 @@ name: build on: push: + branches: + - gh_updates tags: - - 'v[0-9]+.[0-9]+.[0-9]*' + - "v[0-9]+.[0-9]+.[0-9]*" + workflow_dispatch: permissions: contents: read @@ -24,16 +27,48 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha || github.ref }} - - name: Extract tag version - id: tag - run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + fetch-depth: 0 + - name: Generate FMO build version + id: fmo-build-version + shell: bash + run: | + SHA="${{ github.sha }}" + SHORT_SHA="${SHA:0:7}" + REF="${{ github.ref }}" + REF_TYPE="${{ github.ref_type }}" + REF_NAME="${{ github.ref_name }}" + + # Set default to "git-" + FMO_BUILD_VERSION="git-$SHORT_SHA" + + if [[ "$REF_TYPE" == "tag" ]]; then + FMO_BUILD_VERSION="$REF_NAME" + elif [[ "$REF_TYPE" == "branch" ]]; then + # Check if there's a reachable tag on the branch + if git name-rev --name-only --tags --no-undefined "$REF" 2>/dev/null; then + # Format: -<#-of-commits-since-tag>- + FMO_BUILD_VERSION="$(git describe --tags --abbrev=7 "$REF")" + else + # No reachable parent tag on branch + FMO_BUILD_VERSION="$REF_NAME-g$SHORT_SHA" + fi + fi + + echo "SHA: $SHA" + echo "SHORT_SHA: $SHORT_SHA" + echo "REF: $REF" + echo "REF_TYPE: $REF_TYPE" + echo "REF_NAME: $REF_NAME" + echo "FMO_BUILD_VERSION: $FMO_BUILD_VERSION" + echo "{FMO_BUILD_VERSION}={$FMO_BUILD_VERSION}" >> "$GITHUB_ENV" + echo "{FMO_BUILD_VERSION}={$FMO_BUILD_VERSION}" >> "$GITHUB_OUTPUT" - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main with: # this might remove tools that are actually needed, # if set to "true" but frees about 6 GB tool-cache: false - + # all of these default to true, but feel free to set to # "false" if necessary for your workflow android: true @@ -45,24 +80,25 @@ jobs: - name: Build id: build uses: ./.github/actions/build-action + env: + FMO_BUILD_VERSION: "${{ steps.fmo-build-version.outputs.BUILD_VERSION }}" with: - build_target: 'fmo-os-installer-debug' + BUILD_TARGET: "fmo-os-installer-debug" CACHIX_TOKEN: ${{ secrets.CACHIX_TOKEN }} RA_TOKEN: ${{ secrets.RA_TOKEN }} - - name: Push to JFrog artifactory - uses: ./.github/actions/upload-action-jfrog - with: - JFROG_UNAME: ${{ secrets.JFROG_UNAME }} - JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} - JFROG_URL: ${{ secrets.JFROG_URL }} - input-paths: | - ${{ steps.build.outputs.outimg }}:tii-fmo-os/releases/FMO-OS_inst_${{ steps.tag.outputs.TAG_VERSION }}.iso - - name: Push to Harbor artifactory - uses: ./.github/actions/upload-action-harbor - with: - HARBOR_UNAME: ${{ secrets.HARBOR_UNAME }} - HARBOR_TOKEN: ${{ secrets.HARBOR_TOKEN }} - HARBOR_URL: ${{ secrets.HARBOR_URL }} - input-paths: | - ${{ steps.build.outputs.outimg }}:fmo/pmc-installer:${{ steps.tag.outputs.TAG_VERSION }} - + #- name: Push to JFrog artifactory + # uses: ./.github/actions/upload-action-jfrog + # with: + # JFROG_UNAME: ${{ secrets.JFROG_UNAME }} + # JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} + # JFROG_URL: ${{ secrets.JFROG_URL }} + # input-paths: | + # ${{ steps.build.outputs.outimg }}:tii-fmo-os/releases/FMO-OS_inst_${{ steps.fmo-build-version.outputs.BUILD_VERSION }}.iso + #- name: Push to Harbor artifactory + # uses: ./.github/actions/upload-action-harbor + # with: + # HARBOR_UNAME: ${{ secrets.HARBOR_UNAME }} + # HARBOR_TOKEN: ${{ secrets.HARBOR_TOKEN }} + # HARBOR_URL: ${{ secrets.HARBOR_URL }} + # input-paths: | + # ${{ steps.build.outputs.outimg }}:fmo/pmc-installer:${{ steps.fmo-build-version.outputs.BUILD_VERSION }} diff --git a/hardware/fmo-os-rugged-devices.nix b/hardware/fmo-os-rugged-devices.nix index f83bae1..d4ca61b 100644 --- a/hardware/fmo-os-rugged-devices.nix +++ b/hardware/fmo-os-rugged-devices.nix @@ -2,12 +2,17 @@ # SPDX-License-Identifier: Apache-2.0 # # fmo-os-rugged-devices computer -target -{ +let + buildVersion = builtins.getEnv "FMO_BUILD_VERSION"; +in { sysconf = { name = "fmo-os-rugged-devices"; ipaddr = "192.168.101.2"; defaultgw = "192.168.101.1"; - release = "v1.1.0a"; + release = + if buildVersion != "" + then buildVersion + else "v1.1.0a"; fmo-system = { RAversion = "v0.8.4";