Refactor github actions with monorepo support (#783)

* refactor github actions with monorepo support

* Update .github/workflows/release-packages.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update .github/workflows/release-packages.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* updates

* changed order of ci/pr steps

* Update .github/workflows/release-web.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* adding lock file

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Dan Ditomaso
2025-08-18 09:07:13 -04:00
committed by GitHub
co-authored by Copilot
parent 65a53388bb
commit eb9b7159d4
14 changed files with 306 additions and 194 deletions
+40 -20
View File
@@ -10,7 +10,7 @@ on:
required: false
default: ""
tag_name:
description: "Tag to use for artifacts/images (defaults to adhoc-<sha>)"
description: "Tag to use for artifacts/images (defaults to <sha>)"
required: false
default: ""
attach_to_release:
@@ -36,53 +36,56 @@ jobs:
# For manual runs, allow building a chosen ref (branch/tag/SHA)
ref: ${{ inputs.ref != '' && inputs.ref || github.ref }}
- name: Determine tag for this run
- name: Determine tag & latest flag
id: meta
shell: bash
run: |
# tag from release event, or user input, or fallback to adhoc-<shortsha>
# Determine TAG
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
# Push "latest" only for full releases (not prereleases)
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
PUSH_LATEST="false"
else
PUSH_LATEST="true"
fi
elif [ -n "${{ inputs.tag_name }}" ]; then
TAG="${{ inputs.tag_name }}"
PUSH_LATEST="false"
else
SHA="$(git rev-parse --short=12 HEAD)"
TAG="adhoc-${SHA}"
PUSH_LATEST="false"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Resolved tag: $TAG"
# --- Setup Node.js and pnpm ---
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "push_latest=$PUSH_LATEST" >> "$GITHUB_OUTPUT"
echo "Resolved tag: $TAG (push_latest=$PUSH_LATEST)"
# --- Setup Node.js and pnpm (with cache) ---
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: '**/pnpm-lock.yaml'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
# --- Cache pnpm Dependencies ---
- name: Cache pnpm Dependencies
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
packages/web/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create Web App Release Archive
run: pnpm --filter "meshtastic-web" run package
working-directory: packages/web
run: pnpm run package
- name: Upload Web App Archive (artifact)
uses: actions/upload-artifact@v4
with:
name: web-build
name: web-build-${{ steps.meta.outputs.tag }}
if-no-files-found: error
path: packages/web/dist/build.tar
@@ -90,6 +93,7 @@ jobs:
if: ${{ github.event_name == 'release' || inputs.attach_to_release == true }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ steps.meta.outputs.tag }}"
@@ -105,6 +109,22 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Compute image tags
id: tags
shell: bash
run: |
if [ "${{ steps.meta.outputs.push_latest }}" = "true" ]; then
echo "list=latest, ${{ steps.meta.outputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "list=${{ steps.meta.outputs.tag }}" >> "$GITHUB_OUTPUT"
fi
TAGS="latest, ${{ steps.meta.outputs.tag }}"
else
TAGS="${{ steps.meta.outputs.tag }}"
fi
echo "list=$TAGS" >> "$GITHUB_OUTPUT"
echo "Using image tags: $TAGS"
- name: Build Container Image
id: build-container
uses: redhat-actions/buildah-build@v2
@@ -112,7 +132,7 @@ jobs:
containerfiles: |
./packages/web/infra/Containerfile
image: ${{ env.REGISTRY_IMAGE }}
tags: latest, ${{ steps.meta.outputs.tag }}
tags: ${{ steps.tags.outputs.list }}
oci: true
platforms: linux/amd64, linux/arm64