Release #38
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
name: Release | |
on: | |
workflow_dispatch: # Run on manual trigger | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Update NodeJS cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: node_modules/ | |
key: node_modules-${{ github.run_id }} | |
restore-keys: node_modules # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md# | |
- uses: browser-actions/setup-chrome@v1 | |
with: | |
chrome-version: stable | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm install --force | |
- name: Build UI | |
run: npm run build | |
- name: Test UI with stable Chrome | |
run: npm run test:ci | |
- name: Check for lint errors | |
run: npm run lint | |
semantic-release: | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: write # to be able to publish a GitHub release | |
issues: write # to be able to comment on released issues | |
pull-requests: write # to be able to comment on released pull requests | |
id-token: write # to enable use of OIDC for npm provenance | |
outputs: | |
new_release_git_tag: ${{ steps.semantic.outputs.new_release_git_tag }} | |
new_release_version: ${{ steps.semantic.outputs.new_release_version }} | |
new_release_notes: ${{ steps.semantic.outputs.new_release_notes }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
id: semantic | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
needs: semantic-release | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
envs: | |
[ | |
SIM800L_IP5306_VERSION_20190610, | |
SIM800L_AXP192_VERSION_20200327, | |
SIM800C_AXP192_VERSION_20200609, | |
SIM800L_IP5306_VERSION_20200811, | |
T-A7670X, | |
T-A7670X-NO-GPS, | |
T-A7670X-GPS-SHIELD, | |
T-Call-A7670X-V1-0, | |
T-Call-A7670X-V1-1, | |
T-A7608X | |
] | |
outputs: | |
new_release_git_tag: ${{ needs.semantic-release.outputs.new_release_git_tag }} | |
new_release_version: ${{ needs.semantic-release.outputs.new_release_version }} | |
new_release_notes: ${{ needs.semantic-release.outputs.new_release_notes }} | |
env: | |
RELEASE_VERSION: ${{ needs.semantic-release.outputs.new_release_git_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Update PIP cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: pip-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: pip # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Update PlatformIO cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: ~/.platformio | |
key: platformio-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: platformio # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Update Build cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: .pio/ | |
key: build-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: build # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Update NodeJS cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: node_modules/ | |
key: node_modules-${{ github.run_id }} | |
restore-keys: node_modules # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md# | |
- name: Update generated-files cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.pio/build/${{ matrix.envs }}/firmware.bin | |
.pio/build/${{ matrix.envs }}/partitions.bin | |
.pio/build/${{ matrix.envs }}/bootloader.bin | |
.pio/build/${{ matrix.envs }}/littlefs.bin | |
key: generated-files-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install PlatformIO Core | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade platformio | |
- name: Clean old build files | |
run: pio run --target clean -e ${{ matrix.envs }} | |
- name: Build Firmware | |
run: pio run -e ${{ matrix.envs }} | |
- name: Build Filesystem | |
run: pio run --target buildfs -e ${{ matrix.envs }} | |
######################################################################################### | |
## Build Package | |
######################################################################################### | |
package: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
envs: | |
[ | |
SIM800L_IP5306_VERSION_20190610, | |
SIM800L_AXP192_VERSION_20200327, | |
SIM800C_AXP192_VERSION_20200609, | |
SIM800L_IP5306_VERSION_20200811, | |
T-A7670X, | |
T-A7670X-NO-GPS, | |
T-A7670X-GPS-SHIELD, | |
T-Call-A7670X-V1-0, | |
T-Call-A7670X-V1-1, | |
T-A7608X | |
] | |
outputs: | |
new_release_git_tag: ${{ needs.build.outputs.new_release_git_tag }} | |
new_release_version: ${{ needs.build.outputs.new_release_version }} | |
new_release_notes: ${{ needs.build.outputs.new_release_notes }} | |
env: | |
RELEASE_VERSION: ${{ needs.build.outputs.new_release_git_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update PlatformIO cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: ~/.platformio | |
key: platformio-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: platformio # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Update generated-files cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.pio/build/${{ matrix.envs }}/firmware.bin | |
.pio/build/${{ matrix.envs }}/partitions.bin | |
.pio/build/${{ matrix.envs }}/bootloader.bin | |
.pio/build/${{ matrix.envs }}/littlefs.bin | |
key: generated-files-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Update package cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: package | |
key: package-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: package # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Set Variables | |
id: vars | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "branch=$(echo ${{ github.ref_name }} | tr / __)" >> $GITHUB_OUTPUT | |
- name: Prepare package*.zip artifact | |
run: | | |
rm -rf package | |
mkdir -p package | |
rm -rf package/*.zip | |
cp -f ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin "package/boot_app0.bin" | |
cp -f ".pio/build/${{ matrix.envs }}/firmware.bin" "package/firmware.bin" | |
cp -f ".pio/build/${{ matrix.envs }}/bootloader.bin" "package/bootloader.bin" | |
cp -f ".pio/build/${{ matrix.envs }}/partitions.bin" "package/partitions.bin" | |
cp -f ".pio/build/${{ matrix.envs }}/littlefs.bin" "package/littlefs.bin" | |
cd ./package | |
- name: Upload package.zip artifact (Firmware + Bootloader + Partitions + LittleFS) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "OBD2-MQTT-${{ matrix.envs }}-${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" | |
path: ./package | |
######################################################################################### | |
## Prepare and create release artifacts | |
######################################################################################### | |
release-artifacts: | |
runs-on: ubuntu-latest | |
needs: package | |
strategy: | |
matrix: | |
envs: | |
[ | |
SIM800L_IP5306_VERSION_20190610, | |
SIM800L_AXP192_VERSION_20200327, | |
SIM800C_AXP192_VERSION_20200609, | |
SIM800L_IP5306_VERSION_20200811, | |
T-A7670X, | |
T-A7670X-NO-GPS, | |
T-A7670X-GPS-SHIELD, | |
T-Call-A7670X-V1-0, | |
T-Call-A7670X-V1-1, | |
T-A7608X | |
] | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
outputs: | |
new_release_git_tag: ${{ needs.package.outputs.new_release_git_tag }} | |
new_release_version: ${{ needs.package.outputs.new_release_version }} | |
new_release_notes: ${{ needs.package.outputs.new_release_notes }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update package cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: package | |
key: package-${{ github.run_id }}-${{ matrix.envs }} | |
restore-keys: package # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache | |
- name: Prepare artifacts for release | |
run: | | |
rm -rf release | |
mkdir -p release | |
ls -la . | |
cd ./package | |
zip -r ../release/OBD2-MQTT-${{ matrix.envs }}-${{ needs.package.outputs.new_release_git_tag }}.zip . | |
- name: Release artifacts | |
uses: softprops/action-gh-release@v2.0.8 | |
with: | |
tag_name: ${{ needs.package.outputs.new_release_git_tag }} | |
name: ${{ needs.package.outputs.new_release_version }} | |
body: ${{ needs.package.outputs.new_release_notes }} | |
files: | | |
release/* | |
update-web-installer: | |
needs: release-artifacts | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update NodeJS cache on every commit | |
uses: actions/cache@v4 | |
with: | |
path: node_modules/ | |
key: node_modules-${{ github.run_id }} | |
restore-keys: node_modules # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md# | |
- name: Add binary to Web Installer and update manifest | |
run: | | |
devices=(SIM800L_IP5306_VERSION_20190610 SIM800L_AXP192_VERSION_20200327 SIM800C_AXP192_VERSION_20200609 SIM800L_IP5306_VERSION_20200811 T-A7670X T-A7670X-NO-GPS T-A7670X-GPS-SHIELD T-Call-A7670X-V1-0 T-Call-A7670X-V1-1 T-A7608X) | |
echo "Build Web Installer and manifest files..." | |
npm i | |
npm run build:esp-wt | |
npm run build:manifest | |
sed -i 's/$VERSION/${{ needs.release-artifacts.outputs.new_release_git_tag }}/g' docs/index.html | |
echo "Updating Web installer to use firmware from ${{ needs.release-artifacts.outputs.new_release_git_tag }}..." | |
for device in "${devices[@]}" ; do | |
rm -rf docs/binary/$device | |
wget ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.release-artifacts.outputs.new_release_git_tag }}/OBD2-MQTT-$device-${{ needs.release-artifacts.outputs.new_release_git_tag }}.zip | |
mkdir -p docs/binary/$device | |
unzip -o OBD2-MQTT-$device-${{ needs.release-artifacts.outputs.new_release_git_tag }}.zip -d docs/binary/$device | |
sed -i 's/$VERSION/${{ needs.release-artifacts.outputs.new_release_git_tag }}/g' docs/manifest-$device.json | |
done | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: 'docs' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v3 # Note: v4 does not work! |