Release #20
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
# TODO: declare as action so this becomes `uses: blah/espurna-release`? | |
# ref. https://github.com/mcspr/espurna-nightly-builder/blob/builder/.github/workflows/nightly.yml | |
# instead of revision + current date, use tag value as full version of the binary | |
name: Release | |
on: | |
workflow_dispatch: | |
jobs: | |
variables: | |
runs-on: ubuntu-latest | |
outputs: | |
date: ${{ steps.result.outputs.date }} | |
dev: ${{ steps.result.outputs.dev }} | |
master: ${{ steps.result.outputs.master }} | |
steps: | |
- name: Prepare version variables | |
id: result | |
shell: bash | |
run: | | |
revision() { | |
git ls-remote --exit-code --heads https://github.com/xoseperez/espurna.git refs/heads/$1 | cut -d$'\t' -f1 | |
} | |
date=$(date +'%y%m%d') | |
echo "date=${date}" >> "$GITHUB_OUTPUT" | |
dev=$(revision dev) | |
echo "dev=${dev}" >> "$GITHUB_OUTPUT" | |
master=$(revision master) | |
echo "master=${master}" >> "$GITHUB_OUTPUT" | |
build: | |
needs: variables | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
id: [0, 1, 2, 3] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: espurna | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Cache Node | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('espurna/code/package-lock.json', 'espurna/code/package.json') }} | |
- name: Cache PlatformIO | |
uses: actions/cache@v4 | |
with: | |
path: ~/.platformio | |
key: ${{ runner.os }}-platformio-${{ hashFiles('espurna/code/platformio.ini') }} | |
- name: Install PlatformIO | |
run: | | |
pip install -U platformio | |
pio upgrade --dev | |
- name: Build | |
run: | | |
git config --global advice.detachedHead false | |
pushd espurna/code | |
npm ci | |
node node_modules/gulp/bin/gulp.js | |
# each 'id' in matrix only builds every Nth environment | |
# numbers are hard-coded above (...until there's a better idea for doing this) | |
./scripts/generate_release_sh.py \ | |
--ignore secure-client \ | |
--destination ${GITHUB_WORKSPACE}/build \ | |
--builder-id ${{ matrix.id }} \ | |
--builder-total 4 \ | |
--suffix github${{ needs.variables.outputs.date }} \ | |
> release.sh | |
bash release.sh | |
popd | |
- name: Archive | |
run: | | |
pushd build | |
time zip \ | |
--quiet \ | |
--recurse-paths \ | |
../Build_${{ matrix.id }}.zip ./ | |
popd | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Build_${{ matrix.id }} | |
path: Build_${{ matrix.id }}.zip | |
upload: | |
needs: [variables, build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: artifacts/ | |
pattern: Build_* | |
- name: Unpack | |
run: | | |
ls --recursive artifacts | |
unzip -d build "artifacts/*.zip" | |
- name: Prepare debug info | |
run: | | |
time zip \ | |
-9 \ | |
--quiet \ | |
--junk-paths \ | |
--recurse-patterns \ | |
Debug.zip \ | |
'build/debug/*.map' \ | |
'build/debug/*.elf.debug' | |
- name: Fetch release template | |
run: | | |
curl \ | |
-H "Authentication: ${{ secrets.GITUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.VERSION.raw" \ | |
-o release_template.md \ | |
https://api.github.com/repos/xoseperez/espurna/contents/.github/release_template.md | |
- uses: ncipollo/release-action@v1 | |
with: | |
tag: github${{ needs.variables.outputs.date }} | |
commit: ${{ needs.variables.outputs.dev }} | |
name: Snapshot build (github${{ needs.variables.outputs.date }}) | |
bodyFile: "release_template.md" | |
artifacts: "Debug.zip,build/*.bin" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
prerelease: false | |
draft: true |