Skip to content

Commit

Permalink
ci(release): fix release ci
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Sep 27, 2024
1 parent 53c5c81 commit eebb77f
Showing 1 changed file with 83 additions and 34 deletions.
117 changes: 83 additions & 34 deletions .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ jobs:
matrix:
# https://stackoverflow.com/questions/73642596/how-to-cross-compile-rust-across-operating-systems-and-cpu-architectures
job:
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- {
target: aarch64-apple-darwin,
os: macos-latest,
asset: serde-hkx-cli-aarch64-apple-darwin.tar.gz,
}
- {
target: x86_64-pc-windows-msvc,
os: windows-latest,

asset: serde-hkx-cli-x86_64-pc-windows-msvc.zip,
}
- {
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
asset: serde-hkx-cli-x86_64-unknown-linux-gnu.tar.gz,
}
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v4.2.0
Expand All @@ -32,93 +45,129 @@ jobs:

- name: Make outputs dir
run: mkdir -p ./build
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(Windows)
shell: pwsh
if: runner.os == 'Windows'
run: |
Move-Item -Path ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }}.exe -Destination './build'
Move-Item -Path ./LICENSES.toml -Destination './build'
Compress-Archive -Path './build/*' -DestinationPath './serde-hkx-cli-${{ matrix.job.target }}.zip'
Compress-Archive -Path './build/*' -DestinationPath './${{ matrix.job.asset }}'
- name: Release(Windows)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'Windows'
with:
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(MacOS)
shell: bash
if: runner.os == 'macOS'
run: |
mv ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }} ./build
mv ./LICENSES.toml './build'
tar -czf serde-hkx-cli-${{ matrix.job.target }}.tar.gz -C ./build .
tar -czf ${{ matrix.job.asset }} -C ./build .
- name: Release(macOS)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'macOS'
with:
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(Linux)
shell: bash
if: runner.os == 'Linux'
run: |
mv ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }} ./build
mv ./LICENSES.toml './build'
tar -czf serde-hkx-cli-${{ matrix.job.target }}.tar.gz -C ./build .
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.4.0
with:
name: serde-hkx-cli-${{ matrix.job.target }}
path: ./build/

- uses: ncipollo/release-action@v1.14.0
tar -czf ${{ matrix.job.asset }} -C ./build .
- name: Release(Linux)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'Linux'
with:
artifacts: |
serde-hkx-cli-${{ matrix.job.target }}.zip
serde-hkx-cli-${{ matrix.job.target }}.tar.gz
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true

build_extra:
strategy:
fail-fast: false
matrix:
# https://stackoverflow.com/questions/73642596/how-to-cross-compile-rust-across-operating-systems-and-cpu-architectures
job:
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- {
target: aarch64-apple-darwin,
os: macos-latest,
asset: serde-hkx-cli-aarch64-apple-darwin-extra_fmt.tar.gz,
}
- {
target: x86_64-pc-windows-msvc,
os: windows-latest,

asset: serde-hkx-cli-x86_64-pc-windows-msvc-extra_fmt.zip,
}
- {
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
asset: serde-hkx-cli-x86_64-unknown-linux-gnu-extra_fmt.tar.gz,
}
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/checkout@v4.2.0
- name: Rust cache
uses: Swatinem/rust-cache@v2.7.3
with:
prefix-key: cargo-release-${{ matrix.job.target }}-extra
prefix-key: cargo-release-${{ matrix.job.target }}

- name: Build CLI
run: cargo build --release --target ${{ matrix.job.target }} --features extra_fmt

- name: Make outputs dir
run: mkdir -p ./build
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(Windows)
shell: pwsh
if: runner.os == 'Windows'
run: |
Move-Item -Path ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }}.exe -Destination './build'
Move-Item -Path ./LICENSES.toml -Destination './build'
Compress-Archive -Path './build/*' -DestinationPath './serde-hkx-cli-${{ matrix.job.target }}-extra_fmt.zip'
Compress-Archive -Path './build/*' -DestinationPath './${{ matrix.job.asset }}'
- name: Release(Windows)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'Windows'
with:
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(MacOS)
shell: bash
if: runner.os == 'macOS'
run: |
mv ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }} ./build
mv ./LICENSES.toml './build'
tar -czf serde-hkx-cli-${{ matrix.job.target }}-extra_fmt.tar.gz -C ./build .
tar -czf ${{ matrix.job.asset }} -C ./build .
- name: Release(macOS)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'macOS'
with:
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true
# ----------------------------------------------------------------------------------------------------------------
- name: Compress outputs(Linux)
shell: bash
if: runner.os == 'Linux'
run: |
mv ./target/${{ matrix.job.target }}/release/${{ env.APP_NAME }} ./build
mv ./LICENSES.toml './build'
tar -czf serde-hkx-cli-${{ matrix.job.target }}-extra_fmt.tar.gz -C ./build .
- uses: ncipollo/release-action@v1.14.0
tar -czf ${{ matrix.job.asset }} -C ./build .
- name: Release(Linux)
uses: ncipollo/release-action@v1.14.0
if: runner.os == 'Linux'
with:
artifacts: |
serde-hkx-cli-${{ matrix.job.target }}-extra_fmt.zip
serde-hkx-cli-${{ matrix.job.target }}-extra_fmt.tar.gz
artifacts: ${{ matrix.job.asset }}
bodyFile: ./docs/release.md
generateReleaseNotes: true

0 comments on commit eebb77f

Please sign in to comment.