Skip to content

Commit

Permalink
lift more logic out of the github workflow into the makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
obra committed Jan 31, 2024
1 parent 4673236 commit 15fdce0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 55 deletions.
70 changes: 16 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
EXTRA_VERSION: ${{ github.run_number }}

jobs:
metadata:
build:
runs-on: ubuntu-latest
env:
COMMIT_SHA: ${{ github.sha }}
Expand All @@ -24,97 +24,59 @@ jobs:
path: ${{ github.workspace}}/.arduino/downloads
key: ${{ runner.os }}-arduino-downloads
- run: make setup
- run: make all KALEIDOSCOPE_TEMP_PATH=${{ github.workspace}}/.kaleidoscope-temp
- name: Collect the commit SHAs of the build
run: tools/collect-build-info
run: make collect-build-info
- name: Add the NEWS as a changelog to the artifacts
run: cp NEWS.md output/firmware-changelog.md
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: firmwares
path: |
output/

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache arduino dep downloads
uses: actions/cache@v3
with:
path: ${{ github.workspace}}/.arduino/downloads
key: ${{ runner.os }}-arduino-downloads
- run: make setup
- run: make all KALEIDOSCOPE_TEMP_PATH=${{ github.workspace}}/.kaleidoscope-temp
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: firmwares
path: |
output/
publish:
needs: [ metadata, build ]
publish: [ build ]
runs-on: ubuntu-latest
# Ensure this job only runs on pushes to master branch
if: github.ref == 'refs/heads/master'

env:
OUTPUT_DIR: artifacts/firmwares
steps:
- uses: actions/checkout@v3

- name: Discover the version tag
id: version
run: echo ::set-output name=tag::$(make version-tag)
run: |
TAG=$(make version-tag)
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Delete the snapshot release
if: ${{ contains(steps.version.outputs.tag, 'snapshot') }}
if: ${{ contains(env.tag, 'snapshot') }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: ${{ steps.version.outputs.tag }}
shell: bash
run: |
gh release delete -y ${TAG} || true
git tag -d ${TAG} || true
git push origin :${TAG} || true
make delete-tag-and-gh-release
- name: Recreate the snapshot release
if: ${{ contains(steps.version.outputs.tag, 'snapshot') }}
- name: Create the release
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release create -p \
-t "Chrysalis Firmware Bundle $(make version)" \
-F artifacts/firmwares/release-notes.md \
${TAG}
- name: Create the new release
if: ${{ !contains(steps.version.outputs.tag, 'snapshot') }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release create \
-t "Chrysalis Firmware Bundle $(make version)" \
-F artifacts/firmwares/release-notes.md \
${TAG}
make create-gh-release
- name: Package up the artifacts
shell: bash
run: tar -C artifacts/firmwares -czvf firmware-files.tar.gz .
run: |
make package-firmware-build
- name: Upload the firmware files & build info to the release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release upload ${TAG} \
firmware-files.tar.gz \
artifacts/firmwares/build-info.yml \
artifacts/firmwares/firmware-changelog.md
make upload-gh-release
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ update:

pull-kaleidoscope: setup
(cd ${KALEIDOSCOPE_DIR} && git fetch origin && git pull origin master)
git commit -s -m "Updated Kaleidoscope to origin/master" lib/Kaleidoscope
git commit -s -m "Updated Kaleidoscope to origin/master" lib/Kaleidoscope

.env:
echo "ARDUINO_DIRECTORIES_USER=\"${ARDUINO_DIRECTORIES_USER}\"" >.env
Expand All @@ -80,10 +80,33 @@ pull-kaleidoscope: setup
create-snapshot:
./tools/release create-snapshot

collect-build-info:
./tools/collect-build-info


finalize-release:
./tools/release finalize

delete-tag-and-gh-release:
gh release delete -y ${TAG} || true
git tag -d ${TAG} || true
git push origin :${TAG} || true

create-gh-release:
gh release create -p \
-t "Chrysalis Firmware Bundle $(make version)" \
-F ${OUTPUT_DIR}/release-notes.md \
${TAG}

upload-gh-release:
gh release upload ${TAG} \
firmware-files.tar.gz \
${OUTPUT_DIR}/build-info.yml \
${OUTPUT_DIR}/firmware-changelog.md

package-firmware-build:
tar -C ${OUTPUT_DIR} -czvf firmware-files.tar.gz .


.SILENT:
.PHONY: ${BOARDS} clean all message version version-tag setup update .env

0 comments on commit 15fdce0

Please sign in to comment.