Skip to content

Commit

Permalink
Hopefully get binary releases back
Browse files Browse the repository at this point in the history
Using a copy of this file of dua-cli
  • Loading branch information
Byron committed Aug 16, 2021
1 parent b79b0f1 commit be7bb28
Showing 1 changed file with 29 additions and 35 deletions.
64 changes: 29 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@ name: release
on:
push:
# Enable when testing release infrastructure on a branch.
# branches:
# - release
# branches:
# - ag/release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
# env:
# # Set to force version number, e.g., when no tag exists.
# ARTIFACT_VERSION: TEST-0.0.1
# env:
# Set to force version number, e.g., when no tag exists.
# ARTIFACT_VERSION: TEST-0.0.0
steps:
- name: Create artifacts directory
run: mkdir artifacts

- name: Get the release version from the tag
if: env.ARTIFACT_VERSION == ''
run: |
# Apparently, this is the right way to get a tag name. Really?
#
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "::set-env name=ARTIFACT_VERSION::${GITHUB_REF#refs/tags/}"
echo "ARTIFACT_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.ARTIFACT_VERSION }}"
- name: Create GitHub release
Expand All @@ -61,7 +58,7 @@ jobs:

build-release:
name: build-release
needs: ['create-release']
needs: ["create-release"]
runs-on: ${{ matrix.os }}
env:
# For some builds, we use cross to test on 32-bit and big-endian
Expand All @@ -73,24 +70,24 @@ jobs:
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
BIN_NAME: cargo-diet
# The name of the executable to expect
EXE_NAME: cargo-diet
strategy:
matrix:
build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc]
include:
- build: linux
os: ubuntu-18.04
rust: nightly
rust: stable
target: x86_64-unknown-linux-musl
- build: linux-arm
os: ubuntu-18.04
rust: nightly
target: arm-unknown-linux-gnueabihf
- build: macos
os: macos-latest
rust: nightly
rust: stable
target: x86_64-apple-darwin
# no windows support, at least not with GUI (see https://github.com/Byron/dua-cli/issues/2)
- build: win-msvc
os: windows-2019
rust: nightly
Expand All @@ -106,7 +103,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1

Expand All @@ -129,14 +126,12 @@ jobs:
target: ${{ matrix.target }}

- name: Use Cross
# if: matrix.os != 'windows-2019'
run: |
# FIXME: to work around bugs in latest cross release, install master.
# ME: Still needed? Issue seems closed
# See: https://github.com/rust-embedded/cross/issues/357
cargo install --git https://github.com/rust-embedded/cross
echo "::set-env name=CARGO::cross"
echo "::set-env name=TARGET_FLAGS::--target ${{ matrix.target }}"
echo "::set-env name=TARGET_DIR::./target/${{ matrix.target }}"
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
Expand All @@ -154,44 +149,43 @@ jobs:
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "::set-env name=RELEASE_UPLOAD_URL::$release_upload_url"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"
release_version="$(cat artifacts/release-version)"
echo "::set-env name=RELEASE_VERSION::$release_version"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}

- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}"

run: strip "target/${{ matrix.target }}/release/${{ env.EXE_NAME }}"
- name: Strip release binary (arm)
if: matrix.build == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.BIN_NAME }}
/target/arm-unknown-linux-gnueabihf/release/${{ env.EXE_NAME }}
- name: Build archive
shell: bash
run: |
staging="${{ env.BIN_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
staging="${{ env.EXE_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"/complete
cp {README.md,LICENSE.md,CHANGELOG.md} "$staging/"
if [ "${{ matrix.os }}" = "windows-2019" ]; then
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/"
# cp "target/${{ matrix.target }}/release/${{ env.EXE_NAME }}.exe" "$staging/"
cp "target/release/${{ env.EXE_NAME }}.exe" "$staging/"
7z a "$staging.zip" "$staging"
echo "::set-env name=ASSET::$staging.zip"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/"
cp "target/${{ matrix.target }}/release/${{ env.EXE_NAME }}" "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "::set-env name=ASSET::$staging.tar.gz"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
Expand Down

0 comments on commit be7bb28

Please sign in to comment.