Deploy ArduinoIDE library #16
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: "Deploy ArduinoIDE library" | |
on: | |
workflow_dispatch: | |
# Start only after Build was finished | |
workflow_run: | |
workflows: [Build] | |
branches: [main] | |
types: [completed] | |
jobs: | |
check-hsmcpp-version: | |
# only run for successful build after push event | |
# avoid running this action on forks | |
if: ${{ (github.repository == 'igor-krechetov/hsmcpp') && ((github.event.workflow_run == null) || ((github.event.workflow_run.conclusion == 'success') && (github.event.workflow_run.event == 'push'))) }} | |
runs-on: ubuntu-latest | |
outputs: | |
commit_version: ${{ steps.get_version.outputs.commit_version }} | |
commit_action: ${{ steps.get_version.outputs.commit_action }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/workflows/get-commit-version | |
id: get_version | |
with: | |
repo_dir: ${{ env.GITHUB_WORKSPACE }} | |
commit_sha: ${{ github.event.workflow_run.head_sha }} | |
deploy-arduinoide: | |
needs: check-hsmcpp-version | |
# only if commit has version defined and is a release commit | |
if: ${{ (needs.check-hsmcpp-version.outputs.commit_version != '') && (needs.check-hsmcpp-version.outputs.commit_action == 'r') }} | |
runs-on: ubuntu-latest | |
env: | |
target_dir: './arduinoide_deploy/' | |
library_dir: './main/build/deploy/hsmcpp' | |
steps: | |
# need to checkout current repo because workflow is not related with push event | |
- uses: actions/checkout@v3 | |
# checkout repositories | |
- uses: actions/checkout@v3 | |
with: | |
path: './main' | |
- uses: actions/checkout@v3 | |
with: | |
repository: 'igor-krechetov/hsmcpp-arduinoide' | |
token: ${{ secrets.HSMCPP_BOT_TOKEN }} | |
ref: main | |
path: ${{ env.target_dir }} | |
# prepare gpg for commit signing | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }} | |
git_config_global: true | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
workdir: ${{ env.target_dir }} | |
# deploy files | |
- name: Generate hsmcpp package | |
run: | | |
cmake -S ./main -B ./main/build -DHSMBUILD_TARGET=arduinoide -DHSMBUILD_PLATFORM=arduino | |
cmake --build ./main/build --target install | |
mv ./main/build/deploy/arduinoide ${{ env.library_dir }} | |
- name: Install arduino-lint | |
run: | | |
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh | BINDIR=./ sh | |
- name: Validate arduino library structure | |
run: | | |
./arduino-lint --compliance strict --recursive --library-manager update ${{ env.library_dir }} | |
- name: Copy package files to target repository | |
run: cp -Rv ${{ env.library_dir }}/* "$target_dir" | |
- name: Prepare commit message | |
run: | | |
cd ./main | |
git log -1 --format=%B ${{ github.event.workflow_run.head_sha }} > ../commit.txt | |
- name: Publish ArduinoIDE package | |
run: | | |
cd "$target_dir" | |
git add -A | |
git commit -S -F ../commit.txt | |
git tag ${{needs.check-hsmcpp-version.outputs.commit_version}} | |
git push | |
git push --tags |