mirror of
https://github.com/xoseperez/espurna.git
synced 2026-02-20 01:31:34 +01:00
8aacf08c71 incorrect header c/p
ref. https://docs.github.com/en/rest/rate-limit/rate-limit
181 lines
5.3 KiB
YAML
181 lines
5.3 KiB
YAML
# 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:
|
|
build_date: ${{ steps.result.outputs.build_date }}
|
|
build_tag: ${{ steps.result.outputs.build_tag }}
|
|
last_rev: ${{ steps.result.outputs.last_rev }}
|
|
last_tag: ${{ steps.result.outputs.last_tag }}
|
|
|
|
steps:
|
|
- name: Prepare version variables
|
|
id: result
|
|
shell: bash
|
|
run: |
|
|
remote_last_tag() {
|
|
git ls-remote --tags --sort='version:refname' https://github.com/xoseperez/espurna 'github*' |\
|
|
cut -d'/' -f3 |\
|
|
grep -o -E '^github[0-9]{6}$' |\
|
|
sort -r |\
|
|
head -1
|
|
}
|
|
|
|
remote_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 "build_date=${date}" >> "$GITHUB_OUTPUT"
|
|
|
|
tag="github${date}"
|
|
echo "build_tag=${tag}" >> "$GITHUB_OUTPUT"
|
|
|
|
dev=$(remote_revision dev)
|
|
echo "last_rev=${dev}" >> "$GITHUB_OUTPUT"
|
|
|
|
last=$(remote_last_tag)
|
|
echo "last_tag=${last}" >> "$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: |
|
|
# pio libs sometimes use raw hash instead of version, avoid useless warnings
|
|
git config --global advice.detachedHead false
|
|
pushd espurna/code
|
|
|
|
# rebuild existing webui blobs once more
|
|
npm ci
|
|
node node_modules/gulp/bin/gulp.js
|
|
|
|
# github actions allow empty / non-existent output names. check manually
|
|
build_date=${{ needs.variables.outputs.build_date }}
|
|
test -n "$build_date" || exit 2
|
|
|
|
# each 'id' in matrix only builds every Nth environment
|
|
./scripts/generate_release_sh.py \
|
|
--ignore secure-client \
|
|
--destination ${GITHUB_WORKSPACE}/build \
|
|
--builder-id ${{ strategy.job-index }} \
|
|
--builder-total ${{ strategy.job-total }} \
|
|
--suffix github${build_date} \
|
|
> release.sh
|
|
cat 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 and render release template
|
|
run: |
|
|
curl \
|
|
-H "Authorization: Bearer ${{ github.token }}" \
|
|
-H "Accept: application/vnd.github.VERSION.raw" \
|
|
-o release_template.md \
|
|
https://api.github.com/repos/xoseperez/espurna/contents/.github/release_template.md
|
|
|
|
- name: Render release template
|
|
run: |
|
|
sed \
|
|
-i \
|
|
-e 's/\$\$BUILD_TAG\$\$/'${{ needs.variables.outputs.build_tag }}'/g' \
|
|
-e 's/\$\$LAST_TAG\$\$/'${{ needs.variables.outputs.last_tag }}'/g' \
|
|
release_template.md
|
|
|
|
- uses: ncipollo/release-action@v1
|
|
with:
|
|
tag: ${{ needs.variables.outputs.build_tag }}
|
|
commit: ${{ needs.variables.outputs.last_rev }}
|
|
name: Snapshot build (${{ needs.variables.outputs.build_tag }})
|
|
bodyFile: "release_template.md"
|
|
artifacts: "Debug.zip,build/*.bin"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
prerelease: false
|
|
draft: true
|