name: Release Web on: release: types: [released, prereleased] workflow_dispatch: inputs: ref: description: "Git ref (branch, tag, or SHA) to build" required: false default: "" tag_name: description: "Tag to use for artifacts/images (defaults to adhoc-)" required: false default: "" attach_to_release: description: "Upload build.tar to an existing GitHub Release (requires tag_name)" required: false type: boolean default: false permissions: contents: write packages: write env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: release-web: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 with: # For manual runs, allow building a chosen ref (branch/tag/SHA) ref: ${{ inputs.ref != '' && inputs.ref || github.ref }} - name: Determine tag for this run id: meta run: | # tag from release event, or user input, or fallback to adhoc- if [ "${{ github.event_name }}" = "release" ]; then TAG="${{ github.event.release.tag_name }}" elif [ -n "${{ inputs.tag_name }}" ]; then TAG="${{ inputs.tag_name }}" else SHA="$(git rev-parse --short=12 HEAD)" TAG="adhoc-${SHA}" fi echo "tag=$TAG" >> "$GITHUB_OUTPUT" echo "Resolved tag: $TAG" # --- Setup Node.js and pnpm --- - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 22 - 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 - name: Upload Web App Archive (artifact) uses: actions/upload-artifact@v4 with: name: web-build if-no-files-found: error path: packages/web/dist/build.tar - name: Attach Web Archive to GitHub Release if: ${{ github.event_name == 'release' || inputs.attach_to_release == true }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | if [ "${{ github.event_name }}" = "release" ]; then TAG="${{ steps.meta.outputs.tag }}" else if [ -z "${{ inputs.tag_name }}" ]; then echo "attach_to_release requested but no tag_name provided." >&2 exit 1 fi TAG="${{ inputs.tag_name }}" fi gh release upload "$TAG" packages/web/dist/build.tar --clobber - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Build Container Image id: build-container uses: redhat-actions/buildah-build@v2 with: containerfiles: | ./packages/web/infra/Containerfile image: ${{ env.REGISTRY_IMAGE }} tags: latest, ${{ steps.meta.outputs.tag }} oci: true platforms: linux/amd64, linux/arm64 - name: Push Container to GHCR id: push-to-registry uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-container.outputs.image }} tags: ${{ steps.build-container.outputs.tags }} registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Output Image URL run: echo "🖼️ Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}"