Skip to content

Commit

Permalink
ci: reimplement the build script
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com>
  • Loading branch information
AliSajid committed Mar 28, 2024
1 parent caa005c commit cf561d0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- stable
- beta
- nightly
- 1.75.0 # MSRV
- 1.70.0 # MSRV
os:
- windows
- ubuntu
Expand All @@ -69,7 +69,7 @@ jobs:
logo: ubuntu
- os: macos
logo: apple
- rust: 1.75.0 # MSRV
- rust: 1.70.0 # MSRV
label: msrv
- rust: stable
label: stable
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,12 @@ jobs:
run: |
mkdir dist
cp target/${{ matrix.build.target }}/release/${{ matrix.bin }} dist/${{ matrix.bin }}-${{ matrix.build.target }}
- name: Create binary checksum
run: |
shasum --algorithm 256 \
--binary ${{ matrix.bin }}-${{ matrix.build.target }} | tee ${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt
working-directory: ./dist
- name: Upload release artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: ${{ matrix.build.target }}
path: |
dist/${{ matrix.bin }}-${{ matrix.build.target }}
dist/${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt
if-no-files-found: error
retention-days: 1
release:
Expand Down Expand Up @@ -141,17 +135,7 @@ jobs:
- name: ls artifacts
run: tree ./artifacts
- name: Prepare GitHub Release artifacts
run: |
mkdir dist/
cp -vr artifacts/aarch64-apple-darwin dist/aarch64-apple-darwin
cp -vr artifacts/aarch64-unknown-linux-gnu dist/aarch64-unknown-linux-gnu
cp -vr artifacts/i686-unknown-linux-gnu dist/i686-unknown-linux-gnu
cp -vr artifacts/x86_64-apple-darwin dist/x86_64-apple-darwin
cp -vr artifacts/x86_64-unknown-linux-gnu dist/x86_64-unknown-linux-gnu
cp -vr artifacts/x86_64-pc-windows-gnu dist/x86_64-pc-windows-gnu
cp -vr artifacts/i686-pc-windows-gnu dist/i686-pc-windows-gnu
- name: Combine checksums
run: cat dist/**/*-SHA256SUM.txt | tee dist/SHA256SUMS.txt
run: ./scripts/build.sh
- name: Install Conventional Commit preset
run: npm install conventional-changelog-conventionalcommits
- name: Semantic Release
Expand Down
23 changes: 1 addition & 22 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,7 @@ plugins:
- preset: conventionalcommits
- - '@semantic-release/github'
- assets:
- path: dist/aarch64-apple-darwin/gh-bofh-aarch64-apple-darwin
label: gh-bofh-aarch64-apple-darwin
- path: dist/aarch64-unknown-linux-gnu/gh-bofh-aarch64-unknown-linux-gnu
label: gh-bofh-aarch64-unknown-linux-gnu
- path: dist/aarch64-unknown-linux-musl/gh-bofh-aarch64-unknown-linux-musl
label: gh-bofh-aarch64-unknown-linux-musl
- path: dist/i686-unknown-linux-gnu/gh-bofh-i686-unknown-linux-gnu
label: gh-bofh-i686-unknown-linux-gnu
- path: dist/i686-unknown-linux-musl/gh-bofh-i686-unknown-linux-musl
label: gh-bofh-i686-unknown-linux-musl
- path: dist/x86_64-apple-darwin/gh-bofh-x86_64-apple-darwin
label: gh-bofh-x86_64-apple-darwin
- path: dist/x86_64-unknown-linux-gnu/gh-bofh-x86_64-unknown-linux-gnu
label: gh-bofh-x86_64-unknown-linux-gnu
- path: dist/x86_64-unknown-linux-musl/gh-bofh-x86_64-unknown-linux-musl
label: gh-bofh-x86_64-unknown-linux-musl
- path: dist/x86_64-pc-windows-gnu/gh-bofh-x86_64-pc-windows-gnu
label: gh-bofh-x86_64-pc-windows-gnu
- path: dist/i686-pc-windows-gnu/gh-bofh-i686-pc-windows-gnu
label: gh-bofh-i686-pc-windows-gnu
- path: dist/SHA256SUMS
label: SHA256SUMS
- dist/*
- - '@semantic-release/exec'
- verifyConditionsCmd: ~/.cargo/bin/semantic-release-cargo -v verify-conditions
prepareCmd: ~/.cargo/bin/semantic-release-cargo -v prepare ${nextRelease.version}
Expand Down
54 changes: 41 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2024 Ali Sajid Imami
#
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

ls dist/
rm -rfv dist/*
set -euo pipefail
set -x

# Set the necessary variables

# Set the prefix for the binary
PREFIX="gh-bofh"

# Declare the associative array mapping Rust triple to Go arch
declare -A GOARCH_MAP=(
["aarch64-apple-darwin"]="darwin-arm64"
["x86_64-apple-darwin"]="darwin-amd64"
["i686-pc-windows-gnu"]="windows-386"
["x86_64-pc-windows-gnu"]="windows-amd64"
["i686-unknown-linux-gnu"]="linux-386"
["x86_64-unknown-linux-gnu"]="linux-amd64"
["aarch64-unknown-linux-gnu"]="linux-arm64"
)


TAG=${RELEASE_VERSION:-canary}
# Check the files in the source folder
tree artifacts

# Check the files in the dist folder
mkdir -p dist

# Copy binaries with the rust triple and go arch names to the dist folder
for arch in $(basename artifacts/*); do
filename=$PREFIX-$arch
if [ -f "artifacts/$arch/$filename" ]; then
cp -v "artifacts/$arch/$filename" "dist/$filename"
cp -v "artifacts/$arch/$filename" "dist/$PREFIX-${GOARCH_MAP[$arch]}"
fi
done

# Rename the binaries
cp -vr artifacts/aarch64-apple-darwin/gh-bofh-aarch64-apple-darwin dist/gh-bofh_${TAG}_darwin-arm64
cp -vr artifacts/aarch64-unknown-linux-gnu/gh-bofh-aarch64-unknown-linux-gnu dist/gh-bofh_${TAG}_linux-arm64
cp -vr artifacts/i686-unknown-linux-gnu/gh-bofh-i686-unknown-linux-gnu dist/gh-bofh_${TAG}_linux-386
cp -vr artifacts/x86_64-apple-darwin/gh-bofh-x86_64-apple-darwin dist/gh-bofh_${TAG}_darwin-amd64
cp -vr artifacts/x86_64-unknown-linux-gnu/gh-bofh-x86_64-unknown-linux-gnu dist/gh-bofh_${TAG}_linux-amd64
cp -vr artifacts/x86_64-pc-windows-gnu/gh-bofh-x86_64-pc-windows-gnu dist/gh-bofh_${TAG}_windows-amd64.exe
cp -vr artifacts/i686-pc-windows-gnu/gh-bofh-i686-pc-windows-gnu dist/gh-bofh_${TAG}_windows-386.exe

# Create the checksums
shasum -a 256 dist/* > dist/SHA256SUMS.txt
shasum -a 256 dist/* | sed 's/dist\///' | tee dist/SHA256SUMS.txt

# Sign the files
for file in dist/*; do
gpg --armor --output "$file.asc" --detach-sig "$file"
done

tree -a dist/

set +x

0 comments on commit cf561d0

Please sign in to comment.