Skip to content

CD

CD #5

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:
fail-fast: true
matrix:
platform:
- os: ubuntu-latest
artifact_os_name: ubuntu
- os: macos-latest
artifact_os_name: macos
- os: windows-latest
artifact_os_name: windows
runs-on: ${{ matrix.platform.os }}
permissions:
contents: write
outputs:
version: ${{ inputs.version }}
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: Upload macOS artifact
if: matrix.platform.artifact_os_name == 'macos'
uses: actions/upload-artifact@v4
with:
name: https-proxy-${{ matrix.platform.artifact_os_name }}-${{ inputs.version }}
path: https-proxy.app
if-no-files-found: error
- name: Upload Linux/Windows artifact
if: matrix.platform.artifact_os_name != 'macos'
uses: actions/upload-artifact@v4
with:
name: https-proxy-${{ matrix.platform.artifact_os_name }}-${{ inputs.version }}
path: https-proxy
if-no-files-found: error
create_release:
needs: build_and_push
runs-on: ubuntu-latest
permissions:
contents: write # Required to create a release
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/ # Download all artifacts to this directory
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.build_and_push.outputs.version }}
release_name: Release v${{ needs.build_and_push.outputs.version }}
draft: true
prerelease: false
- name: Upload Release Assets
shell: bash
run: |
for file_path in artifacts/*/*; do
if [ -f "$file_path" ]; then
asset_name=$(basename "$file_path")
echo "Uploading $asset_name from $file_path"
gh release upload v${{ needs.build_and_push.outputs.version }} "$file_path" --clobber
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}