Skip to content

CD

CD #4

Workflow file for this run

name: CD
on:
# 输入version
workflow_dispatch:
inputs:
version:
description: 'version number'
required: true
default: '0.1.0'
jobs:
build_and_push:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: temurin:21
apps: sbt bloop sbtn
- name: Run SBT stage
run: sbt clean stage
- name: package
run: jpackage --name https-proxy --input target/universal/stage/lib --main-jar https-proxy.https-proxy-${{ inputs.version }}.jar --main-class Main --type app-image
- name: Archive macOS app bundle
if: matrix.os == 'macos-latest'
run: |
EXPECTED_APP_DIR="https-proxy.app"
ARCHIVE_NAME="https-proxy-macos-${{ inputs.version }}.zip"
if [ -d "$EXPECTED_APP_DIR" ]; then
zip -r "$ARCHIVE_NAME" "$EXPECTED_APP_DIR"
echo "macOS artifact zipped to $ARCHIVE_NAME"
else
echo "Error: $EXPECTED_APP_DIR not found in current directory. Listing contents:"
ls -lah
# Attempt to find it if jpackage placed it inside 'https-proxy' folder
if [ -d "https-proxy/$EXPECTED_APP_DIR" ]; then
echo "Found $EXPECTED_APP_DIR inside 'https-proxy' directory. Zipping from there."
(cd https-proxy && zip -r "../$ARCHIVE_NAME" "$EXPECTED_APP_DIR")
echo "macOS artifact zipped to $ARCHIVE_NAME from https-proxy/$EXPECTED_APP_DIR"
else
echo "Still cannot find $EXPECTED_APP_DIR. Exiting."
exit 1
fi
fi
- name: Debug macOS jpackage output
if: matrix.os == 'macos-latest'
run: |
pwd
echo "--- Listing current directory ---"
ls -lah
echo "--- Listing target/universal/stage ---"
ls -lah target/universal/stage
echo "--- Listing expected jpackage output location (if it's a directory) ---"
ls -lah https-proxy || echo "Directory https-proxy not found or ls failed"
echo "--- Check if https-proxy.app exists ---"
ls -lah *.app || echo "No .app files found in current directory"
- name: Upload macOS artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: https-proxy-${{ matrix.os }}-${{ inputs.version }}
path: https-proxy-macos-${{ inputs.version }}.zip
if-no-files-found: error
- name: Upload Linux/Windows artifact
if: matrix.os != 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: https-proxy-${{ matrix.os }}-${{ inputs.version }}
path: https-proxy
if-no-files-found: error