mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-01 17:10:21 +00:00
Fix release CI (#797)
This commit is contained in:
parent
267ce7672e
commit
ab5dd00b86
2
.github/workflows/all-tests-slow.yml
vendored
2
.github/workflows/all-tests-slow.yml
vendored
@ -14,4 +14,4 @@ jobs:
|
||||
uses: ./.github/workflows/build-artifacts-and-run-tests.yml
|
||||
with:
|
||||
matrix_all_combinations: true
|
||||
upload_artifacts: false
|
||||
artifact_upload_mode: none
|
||||
|
@ -10,20 +10,23 @@ on:
|
||||
type: boolean
|
||||
required: true
|
||||
default: true
|
||||
upload_artifacts:
|
||||
description: "if built artifacts should be uploaded"
|
||||
type: boolean
|
||||
artifact_upload_mode:
|
||||
description: "Control what artifacts to upload: 'none' for no uploads, 'with_default_features' to upload artifacts with default features (for releases), or 'all' for all feature combinations."
|
||||
type: choice
|
||||
options:
|
||||
- none
|
||||
- with_default_features
|
||||
- all
|
||||
required: true
|
||||
default: true
|
||||
workflow_call:
|
||||
inputs:
|
||||
matrix_all_combinations:
|
||||
description: "if matrix should have all combinations of targets and features"
|
||||
type: boolean
|
||||
required: true
|
||||
upload_artifacts:
|
||||
description: "if built artifacts should be uploaded"
|
||||
type: boolean
|
||||
artifact_upload_mode:
|
||||
description: "Control which artifacts to upload: 'none' for no uploads, 'with_default_features' to upload only artifacts with default features (use_zlib+use_zstd_thin+unrar), or 'all' to upload all feature combinations."
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
@ -102,12 +105,16 @@ jobs:
|
||||
if [[ "${{ matrix.feature-use-zlib }}" == true ]]; then FEATURES+=(use_zlib); fi
|
||||
if [[ "${{ matrix.feature-use-zstd-thin }}" == true ]]; then FEATURES+=(use_zstd_thin); fi
|
||||
if [[ "${{ matrix.feature-unrar }}" == true ]]; then FEATURES+=(unrar); fi
|
||||
# Output plus-separated list for artifact names
|
||||
IFS='+'
|
||||
echo "FEATURES_PLUS=${FEATURES[*]}" >> $GITHUB_OUTPUT
|
||||
# Output comma-separated list for cargo flags
|
||||
IFS=','
|
||||
echo "FEATURES=${FEATURES[*]}" >> $GITHUB_OUTPUT
|
||||
echo "FEATURES_COMMA=${FEATURES[*]}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up extra cargo flags
|
||||
env:
|
||||
FEATURES: ${{steps.concat-features.outputs.FEATURES}}
|
||||
FEATURES: ${{steps.concat-features.outputs.FEATURES_COMMA}}
|
||||
shell: bash
|
||||
run: |
|
||||
FLAGS="--no-default-features"
|
||||
@ -133,13 +140,16 @@ jobs:
|
||||
run: |
|
||||
${{ env.CARGO }} +stable build --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
|
||||
env:
|
||||
OUCH_ARTIFACTS_FOLDER: artifacts
|
||||
OUCH_ARTIFACTS_FOLDER: man-page-and-completions-artifacts
|
||||
|
||||
- name: Upload release artifacts
|
||||
if: ${{ inputs.upload_artifacts }}
|
||||
if: |
|
||||
${{ inputs.artifact_upload_mode != 'none' &&
|
||||
(inputs.artifact_upload_mode == 'all' ||
|
||||
(matrix.feature-unrar && matrix.feature-use-zlib && matrix.feature-use-zstd-thin)) }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ouch-${{ matrix.target }}-${{ steps.concat-features.outputs.FEATURES }}
|
||||
name: ouch-${{ matrix.target }}${{ steps.concat-features.outputs.FEATURES_PLUS != '' && format('-{0}', steps.concat-features.outputs.FEATURES_PLUS) || '' }}
|
||||
path: |
|
||||
target/${{ matrix.target }}/release/ouch
|
||||
target/${{ matrix.target }}/release/ouch.exe
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
uses: ./.github/workflows/build-artifacts-and-run-tests.yml
|
||||
with:
|
||||
matrix_all_combinations: true
|
||||
upload_artifacts: true
|
||||
artifact_upload_mode: with_default_features
|
||||
|
||||
automated-draft-release:
|
||||
runs-on: ubuntu-latest
|
||||
@ -23,7 +23,9 @@ jobs:
|
||||
- name: Download artifacts
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
path: artifacts
|
||||
path: downloaded_artifacts
|
||||
workflow: ./.github/workflows/build-artifacts-and-run-tests.yml
|
||||
name: ouch-*
|
||||
|
||||
- name: Package release assets
|
||||
run: scripts/package-release-assets.sh
|
||||
@ -32,4 +34,4 @@ jobs:
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
draft: true
|
||||
files: release/ouch-*
|
||||
files: output_assets/ouch-*
|
||||
|
@ -1,32 +0,0 @@
|
||||
name: Manual trigger draft release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run_id:
|
||||
description: Run id of the action run to pull artifacts from
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
create-draft-release-from-manual-trigger:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download artifacts
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
path: artifacts
|
||||
workflow: build-artifacts-and-run-tests.yml
|
||||
run_id: ${{ github.event.inputs.run_id }}
|
||||
|
||||
- name: Package release assets
|
||||
run: scripts/package-release-assets.sh
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
draft: true
|
||||
name: manual release ${{ github.event.inputs.run_id }}
|
||||
files: release/ouch-*
|
2
.github/workflows/pr-workflow.yml
vendored
2
.github/workflows/pr-workflow.yml
vendored
@ -32,4 +32,4 @@ jobs:
|
||||
uses: ./.github/workflows/build-artifacts-and-run-tests.yml
|
||||
with:
|
||||
matrix_all_combinations: false
|
||||
upload_artifacts: false
|
||||
artifact_upload_mode: none
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "ouch"
|
||||
version = "0.5.1"
|
||||
authors = [
|
||||
"João M. Bezerra <marcospb19@hotmail.com>",
|
||||
"João Marcos <marcospb19@hotmail.com>",
|
||||
"Vinícius Rodrigues Miguel <vrmiguel99@gmail.com>",
|
||||
]
|
||||
edition = "2021"
|
||||
@ -70,7 +70,7 @@ regex = "1.10.4"
|
||||
test-strategy = "0.4.0"
|
||||
|
||||
[features]
|
||||
default = ["use_zlib", "use_zstd_thin", "unrar"]
|
||||
default = ["unrar", "use_zlib", "use_zstd_thin"]
|
||||
use_zlib = ["flate2/zlib", "gzp/deflate_zlib", "zip/deflate-zlib"]
|
||||
use_zstd_thin = ["zstd/thin"]
|
||||
allow_piped_choice = []
|
||||
|
10
build.rs
10
build.rs
@ -5,18 +5,12 @@
|
||||
/// Set `OUCH_ARTIFACTS_FOLDER` to the name of the destination folder:
|
||||
///
|
||||
/// ```sh
|
||||
/// OUCH_ARTIFACTS_FOLDER=my-folder cargo build
|
||||
/// OUCH_ARTIFACTS_FOLDER=man-page-and-completions-artifacts cargo build
|
||||
/// ```
|
||||
///
|
||||
/// All completion files will be generated inside of the folder "my-folder".
|
||||
/// All completion files will be generated inside of the folder "man-page-and-completions-artifacts".
|
||||
///
|
||||
/// If the folder does not exist, it will be created.
|
||||
///
|
||||
/// We recommend you naming this folder "artifacts" for the sake of consistency.
|
||||
///
|
||||
/// ```sh
|
||||
/// OUCH_ARTIFACTS_FOLDER=artifacts cargo build
|
||||
/// ```
|
||||
use std::{
|
||||
env,
|
||||
fs::{create_dir_all, File},
|
||||
|
@ -1,28 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
mkdir release
|
||||
cd artifacts
|
||||
mkdir -p output_assets
|
||||
cd downloaded_artifacts
|
||||
|
||||
for dir in ouch-*; do
|
||||
cp -r "$dir/artifacts" "$dir/completions"
|
||||
mkdir "$dir/man"
|
||||
mv "$dir"/completions/*.1 "$dir/man"
|
||||
TARGETS=(
|
||||
"aarch64-pc-windows-msvc"
|
||||
"aarch64-unknown-linux-gnu"
|
||||
"aarch64-unknown-linux-musl"
|
||||
"armv7-unknown-linux-gnueabihf"
|
||||
"armv7-unknown-linux-musleabihf"
|
||||
"x86_64-apple-darwin"
|
||||
"x86_64-pc-windows-gnu"
|
||||
"x86_64-pc-windows-msvc"
|
||||
"x86_64-unknown-linux-gnu"
|
||||
"x86_64-unknown-linux-musl"
|
||||
)
|
||||
DEFAULT_FEATURES="unrar+use_zlib+use_zstd_thin"
|
||||
|
||||
cp ../{README.md,LICENSE,CHANGELOG.md} "$dir"
|
||||
rm -r "$dir/artifacts"
|
||||
for target in "${TARGETS[@]}"; do
|
||||
input_dir="ouch-${target}-${DEFAULT_FEATURES}"
|
||||
|
||||
if [[ "$dir" = *.exe ]]; then
|
||||
target=${dir%.exe}
|
||||
mv "$dir/target/${target/ouch-/}/release/ouch.exe" "$dir"
|
||||
rm -r "$dir/target"
|
||||
mv "$dir" "$target"
|
||||
zip -r "../release/$target.zip" "$target"
|
||||
if [ ! -d "$input_dir" ]; then
|
||||
echo "ERROR: Could not find artifact directory for $target with default features ($input_dir)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Processing $input_dir"
|
||||
|
||||
cp ../{README.md,LICENSE,CHANGELOG.md} "$input_dir"
|
||||
mkdir -p "$input_dir/man"
|
||||
mkdir -p "$input_dir/completions"
|
||||
|
||||
mv "$input_dir"/man-page-and-completions-artifacts/*.1 "$input_dir/man"
|
||||
mv "$input_dir"/man-page-and-completions-artifacts/* "$input_dir/completions"
|
||||
rm -r "$input_dir/man-page-and-completions-artifacts"
|
||||
|
||||
output_name="ouch-${target}"
|
||||
|
||||
if [[ "$target" == *"-windows-"* ]]; then
|
||||
mv "$input_dir/target/$target/release/ouch.exe" "$input_dir"
|
||||
rm -rf "$input_dir/target"
|
||||
|
||||
zip -r "../output_assets/${output_name}.zip" "$input_dir"
|
||||
echo "Created output_assets/${output_name}.zip"
|
||||
else
|
||||
mv "$dir/target/${dir/ouch-/}/release/ouch" "$dir"
|
||||
rm -r "$dir/target"
|
||||
chmod +x "$dir/ouch"
|
||||
tar czf "../release/$dir.tar.gz" "$dir"
|
||||
mv "$input_dir/target/$target/release/ouch" "$input_dir"
|
||||
rm -rf "$input_dir/target"
|
||||
chmod +x "$input_dir/ouch"
|
||||
|
||||
tar czf "../output_assets/${output_name}.tar.gz" "$input_dir"
|
||||
echo "Created output_assets/${output_name}.tar.gz"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
|
Loading…
x
Reference in New Issue
Block a user