Skip to content

Commit

Permalink
Extract more of our releng workflow from the github actions to make it
Browse files Browse the repository at this point in the history
more maintainable

Improve generation of snapshot releases
  • Loading branch information
obra committed Jan 31, 2024
1 parent 4673236 commit 4fc08b7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 66 deletions.
90 changes: 28 additions & 62 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,111 +10,77 @@ on:
env:
LC_ALL: C
EXTRA_VERSION: ${{ github.run_number }}

jobs:
metadata:
build:
runs-on: ubuntu-latest
env:
COMMIT_SHA: ${{ github.sha }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Discover the version tag
id: version
run: |
TAG=$(make version-tag)
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Cache arduino dep downloads
uses: actions/cache@v3
uses: actions/cache@v4
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: 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
uses: actions/upload-artifact@v4
with:
name: firmwares
name: firmware-build
path: |
output/
publish:
needs: [ metadata, build ]
needs: 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/firmware-build
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v4
- 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
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Delete the snapshot release
if: ${{ contains(steps.version.outputs.tag, 'snapshot') }}
- name: Delete the snapshot release and update the tag
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 update-tag-and-delete-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
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ clean:

setup:
git submodule update --init --recursive
(cd ${KALEIDOSCOPE_DIR} && make setup)
(cd ${KALEIDOSCOPE_DIR} && make setup && make update)

update:
git submodule update --init --recursive
Expand All @@ -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,34 @@ pull-kaleidoscope: setup
create-snapshot:
./tools/release create-snapshot

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


finalize-release:
./tools/release finalize

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

create-gh-release:
gh release create -p \
-t "Chrysalis Firmware Bundle $(EMBEDDED_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
4 changes: 2 additions & 2 deletions tools/collect-build-info
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extract_current_news() {
install -d output

cat >output/release-notes.md <<EOF
Chrysalis Firmware Bundle $(make version)
Chrysalis Firmware Bundle $(make --no-print-directory version)
## Build Information
Expand All @@ -109,7 +109,7 @@ EOF

cat >output/build-info.yml <<EOF
---
version: $(make version)
version: $(make --no-print-directory version)
build: ${GITHUB_RUN_NUMBER}
dependencies:
Expand Down

0 comments on commit 4fc08b7

Please sign in to comment.