Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
name: Fetch Firmware
|
||||
|
||||
# The firmware is built by the upstream repository
|
||||
# (mnh-jansson/open-battery-information) and attached to its GitHub
|
||||
# releases. This workflow simply downloads the latest binaries and commits
|
||||
# them here, so the uploader always serves the newest firmware without
|
||||
# needing a local PlatformIO toolchain.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
fetch:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download firmware from the upstream release
|
||||
run: |
|
||||
curl -fL --retry 5 --retry-delay 10 -o firmware/uno.hex \
|
||||
https://github.com/mnh-jansson/open-battery-information/releases/latest/download/uno.hex
|
||||
curl -fL --retry 5 --retry-delay 10 -o firmware/esp32.bin \
|
||||
https://github.com/mnh-jansson/open-battery-information/releases/latest/download/esp32.bin
|
||||
|
||||
- name: Show the upstream release this firmware came from
|
||||
run: |
|
||||
curl -fsSL https://api.github.com/repos/mnh-jansson/open-battery-information/releases/latest \
|
||||
| python3 -c "import json, sys; r = json.load(sys.stdin); print('upstream tag:', r['tag_name'], '| published:', r['published_at'])"
|
||||
|
||||
- name: Commit updated firmware
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: 'ci: fetch latest ArduinoOBI firmware from upstream release'
|
||||
file_pattern: firmware/uno.hex firmware/esp32.bin
|
||||
@@ -0,0 +1,149 @@
|
||||
name: Package desktop app
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag to attach the installers to (leave empty for workflow_dispatch only build)"
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
name: Sync desktop version to tag
|
||||
if: github.event_name == 'push'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Bump desktop package version
|
||||
working-directory: desktop
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
npm pkg set version="$VERSION"
|
||||
npm install --package-lock-only
|
||||
echo "bumped desktop version to $VERSION"
|
||||
|
||||
- name: Commit and push version bump
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add desktop/package.json desktop/package-lock.json
|
||||
if git diff --cached --quiet; then
|
||||
echo "no version change to commit"
|
||||
else
|
||||
git commit -m "bump desktop version to ${GITHUB_REF_NAME#v} [ci skip]"
|
||||
git push origin HEAD:main
|
||||
fi
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
script: dist:win
|
||||
env: { CSC_IDENTITY_AUTO_DISCOVERY: "true" }
|
||||
- os: macos-latest
|
||||
script: dist:mac
|
||||
env: { CSC_IDENTITY_AUTO_DISCOVERY: "false" }
|
||||
- os: ubuntu-latest
|
||||
script: dist:linux
|
||||
env: { CSC_IDENTITY_AUTO_DISCOVERY: "true" }
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
cache-dependency-path: desktop/package-lock.json
|
||||
|
||||
- name: Cache Electron binaries
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
~/.cache/electron-builder
|
||||
key: ${{ runner.os }}-electron-${{ hashFiles('desktop/package-lock.json') }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: desktop
|
||||
|
||||
- name: Set version from release tag
|
||||
env:
|
||||
TAG: ${{ inputs.tag != '' && inputs.tag || github.ref_name }}
|
||||
working-directory: desktop
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="${TAG#v}"
|
||||
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
||||
npm pkg set version="$VERSION"
|
||||
echo "Packaging version $VERSION"
|
||||
else
|
||||
echo "No semver tag ($TAG) - keeping package.json version"
|
||||
fi
|
||||
|
||||
- name: Build installers
|
||||
run: npm run ${{ matrix.script }}
|
||||
working-directory: desktop
|
||||
env:
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: ${{ matrix.env.CSC_IDENTITY_AUTO_DISCOVERY }}
|
||||
|
||||
- name: List release artifacts
|
||||
shell: bash
|
||||
working-directory: desktop
|
||||
run: ls -la release
|
||||
|
||||
- name: Upload installers
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: installers-${{ matrix.os }}
|
||||
path: |
|
||||
desktop/release/*.exe
|
||||
desktop/release/*.dmg
|
||||
desktop/release/*.zip
|
||||
desktop/release/*.AppImage
|
||||
desktop/release/*.deb
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
name: Publish release
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/') || inputs.tag != ''
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download installers
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: Publish GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
||||
files: |
|
||||
artifacts/*.exe
|
||||
artifacts/*.dmg
|
||||
artifacts/*.zip
|
||||
artifacts/*.AppImage
|
||||
artifacts/*.deb
|
||||
generate_release_notes: true
|
||||
@@ -0,0 +1,40 @@
|
||||
name: Deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Configure Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Stage web files
|
||||
run: |
|
||||
mkdir -p _site
|
||||
cp -r index.html obi.html setup.html download.html css js firmware assets _site/
|
||||
|
||||
- name: Upload Pages artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: _site
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
Reference in New Issue
Block a user