gh-actions: Initial commit of svalboard build workflow. #2
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: Release QMK Firmware | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
uses: ./.github/workflows/build-firmware.yml | |
with: | |
keyboard: ${{ matrix.keyboard }} | |
keymap: ${{ matrix.keymap }} | |
side: ${{ matrix.side }} | |
strategy: | |
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
generate-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set matrix | |
id: set-matrix | |
run: | | |
JSON_MATRIX=$(cat .github/matrix.yml | jq -c) | |
echo "::set-output name=matrix::$JSON_MATRIX" | |
release: | |
needs: [build, generate-matrix] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download firmware artifacts | |
uses: actions/download-artifact@v2 | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Upload firmware to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
UPLOAD_URL: ${{ steps.create_release.outputs.upload_url }} | |
run: | | |
matrix=${{ toJson(fromJson(needs.generate-matrix.outputs.matrix)) }} | |
for row in $(echo "$matrix" | jq -c '.[]'); do | |
keyboard=$(echo "$row" | jq -r '.keyboard') | |
side=$(echo "$row" | jq -r '.side') | |
asset_path="./firmware-$keyboard-$side/$keyboard_$side_default_${{ github.ref_name }}.uf2" | |
asset_name="${keyboard}_${side}_default_${{ github.ref_name }}.uf2" | |
curl -X POST \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary "@$asset_path" \ | |
"$UPLOAD_URL?name=$asset_name" | |
done | |