Releng improvements (#224)

This commit is contained in:
Félix Saparelli 2022-07-24 00:39:54 +12:00 committed by GitHub
parent 1768392413
commit 3889d122a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 240 additions and 33 deletions

View file

@ -13,7 +13,6 @@ env:
jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -22,45 +21,39 @@ jobs:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
output: cargo-binstall
archive: tgz
use-cross: false
test: true
- target: x86_64-apple-darwin
os: macos-latest
output: cargo-binstall
archive: zip
use-cross: false
test: true
- target: aarch64-apple-darwin
os: macos-latest
output: cargo-binstall
archive: zip
use-cross: false
test: false
- target: x86_64-pc-windows-msvc
os: windows-latest
output: cargo-binstall.exe
archive: zip
use-cross: false
test: false
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
output: cargo-binstall
archive: tgz
use-cross: false
test: true
- target: armv7-unknown-linux-musleabihf
os: ubuntu-20.04
output: cargo-binstall
archive: tgz
use-cross: true
test: false
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
output: cargo-binstall
archive: tgz
use-cross: true
test: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@ -122,30 +115,74 @@ jobs:
./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall
cargo binstall --help
- name: Create archive (tgz, linux)
if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }}
run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }}
- name: Create archive (zip, windows)
if: ${{ matrix.os == 'windows-latest' }}
run: tar.exe -a -c -f cargo-binstall-${{ matrix.target }}.zip ${{ matrix.output }}
- name: Create archive (zip, macos)
if: ${{ matrix.os == 'macos-latest' }}
run: zip cargo-binstall-${{ matrix.target }}.zip ${{ matrix.output }}
- name: Upload artifacts
uses: actions/upload-artifact@v1
- name: Upload output
uses: actions/upload-artifact@v3
with:
name: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }}
path: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }}
retention-days: 1
name: "${{ matrix.target }}.${{ matrix.output }}"
path: "${{ matrix.output }}"
- name: Upload binary to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
release:
name: Package and release
needs: build
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get outputs
uses: actions/download-artifact@v3
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }}
asset_name: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }}
tag: ${{ github.ref }}
overwrite: true
path: outputs/
- name: Create archives
shell: bash
run: |
set -euxo pipefail
for o in outputs/*; do
pushd "$o"
cp ../../LICENSE.txt ../../README.md .
target=$(basename "$o" | cut -d. -f1)
if grep -qE '(apple|windows)' <<< "$target"; then
zip "../cargo-binstall-${target}.zip" *
else
tar cvf "../cargo-binstall-${target}.tgz" *
fi
popd
done
- name: Extract release notes
id: notes
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
release_commit: ${{ github.event.head_commit.message }}
run: |
set -euxo pipefail
release_pr=$(head -n1 <<< "${release_commit:-}" | jq -Rr 'split("[()]"; "")[1] // ""')
if [[ -z "$release_pr" ]]; then
echo "::set-output name=notes_json::null"
exit
fi
gh \
pr --repo "$GITHUB_REPO" \
view "$release_pr" \
--json body \
--jq '"::set-output name=notes_json::\((.body | split("### Release notes")[1] // "") | tojson)"'
- name: Publish release
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref }}
body: ${{ fromJSON(steps.notes.outputs.notes_json) }}
append_body: true
files: |
outputs/cargo-binstall-*.zip
outputs/cargo-binstall-*.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}