ci: build all and deploy releases from tags

When you push a version tag (v1.15.0), this workflow will automatically
create a github release (as draft) and upload all the built artifacts
(*.px4 files).

Additionally, you can now also trigger this step manually using the
github actions view URL

https://github.com/PX4/PX4-Autopilot/actions/workflows/build_all_targets.yml
This commit is contained in:
Ramon Roche 2024-09-20 09:14:06 -07:00 committed by Daniel Agar
parent 7d0e93b779
commit 8ae83a8197

View File

@ -6,15 +6,22 @@
name: Build all targets
on:
workflow_dispatch:
inputs:
tag:
required: true
description: release version
push:
tags:
- 'v*'
branches:
- 'main'
- 'stable'
- 'beta'
- 'release/*'
- 'main'
- 'stable'
- 'beta'
- 'release/**'
pull_request:
branches:
- '*'
- '*'
jobs:
group_targets:
@ -24,6 +31,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
timestamp: ${{ steps.set-timestamp.outputs.timestamp }}
tagname: ${{ steps.set-tag.outputs.tagname }}
steps:
- uses: actions/checkout@v4
@ -38,8 +46,22 @@ jobs:
- id: set-timestamp
run: echo "::set-output name=timestamp::$(date +"%Y%m%d%H%M%S")"
# This job is also triggered with versioned tags
# Creating a and pushing a tag starting with "v" just as "v1.0.0"
# will trigger this workflow and when all builds are done create a Github Release
# then it will upload all binaries built as assets
# Additionally, we can also trigger this step manually
# From the Github Actions tab for this repository:
# https://github.com/PX4/PX4-Autopilot/actions/workflows/build_all_targets.yml
# You can now click a "Run Workflow" button that will prompt you for a tag name
# This tag name has to match an existing tag otherwise the new release will be detached
# Note: Only developers with "write" permission to the repository can use this feature
- id: set-tag
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
run: echo "::set-output name=tagname::${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
setup:
name: ${{ matrix.group }}
name: Build Group [${{ matrix.group }}]
# runs-on: ubuntu-latest
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu22-full-x64,"run-id=${{ github.run_id }}"]
needs: group_targets
@ -73,7 +95,7 @@ jobs:
ccache -s
ccache -z
- name: build target group
- name: building [${{ matrix.group }}]
run: |
./Tools/ci_build_all_runner.sh ${{matrix.targets}}
@ -88,3 +110,26 @@ jobs:
- name: ccache post-run
run: ccache -s
release:
name: Release and Upload
# runs-on: ubuntu-latest
runs-on: [runs-on,runner=1cpu-linux-x64,image=ubuntu22-full-x64,"run-id=${{ github.run_id }}"]
needs: [setup, group_targets]
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Arrange Binaries
run: |
mkdir artifacts
cp **/**/*.px4 artifacts/
- name: Upload Binaries
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.group_targets.outputs.tagname }}
tag_name: ${{ needs.group_targets.outputs.tagname }}
draft: true
files: artifacts/*.px4