ci: automatically create github releases on tags

This commit is contained in:
figsoda 2022-11-20 15:42:08 -05:00
parent c622ee9dac
commit 697979bd99
4 changed files with 78 additions and 21 deletions

View File

@ -111,3 +111,26 @@ jobs:
rustup toolchain install nightly --profile minimal -c rustfmt
cargo +stable clippy -- -D warnings
cargo +nightly fmt -- --check
github-release:
name: github-release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
with:
path: artifacts
- name: Package release assets
run: scripts/package-release-assets.sh
- name: Create release
uses: softprops/action-gh-release@v1
with:
draft: true
files: release/ouch-*

33
.github/workflows/manual-release.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: manual-release
on:
workflow_dispatch:
inputs:
run_id:
description: Run id of the action run to pull artifacts from
required: true
jobs:
github-release:
name: github-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
with:
path: artifacts
workflow: build-and-test.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@v1
with:
draft: true
name: manual release ${{ github.event.inputs.run_id }}
files: release/ouch-*

View File

@ -1,21 +0,0 @@
#! /usr/bin/sh
#
# Small script to help decompressing files from the CI to make manual releases
set -e
ouch --version
rm release -r || true
ouch decompress ouch-x86_64-pc-windows-msvc.exe.zip --dir release
mv release/ouch.exe release/ouch-x86_64-pc-windows-msvc.exe
ouch decompress ouch-x86_64-apple-darwin.zip --dir release
mv release/ouch release/ouch-x86_64-apple-darwin
ouch decompress ouch-x86_64-unknown-linux-musl.zip --dir release
mv release/ouch release/ouch-x86_64-linux-musl
dragon-drag-and-drop release/*

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
mkdir release
cd artifacts
for dir in ouch-*; do
cp -r artifacts "$dir/completions"
mkdir "$dir/man"
mv "$dir"/completions/*.1 "$dir/man"
cp ../{README.md,LICENSE,CHANGELOG.md} "$dir"
if [[ "$dir" = *.exe ]]; then
target=${dir%.exe}
mv "$dir" "$target"
zip -r "../release/$target.zip" "$target"
else
chmod +x "$dir/ouch"
tar czf "../release/$dir.tar.gz" "$dir"
fi
done