Release Analytics CLI #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Analytics CLI | |
on: | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
type: string | |
description: Tag to create | |
required: True | |
concurrency: ${{ github.workflow }} | |
jobs: | |
build_linux: | |
name: Build ${{ matrix.target }} | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
artifact-name: x86_64-unknown-linux | |
runs-on: public-amd64-2xlarge | |
- target: aarch64-unknown-linux-musl | |
artifact-name: aarch64-unknown-linux | |
runs-on: public-arm64-2xlarge | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
- name: Update version | |
run: | | |
export VERSION=${{ github.event.inputs.release_tag }} | |
sed -i "s/0.0.0/$VERSION/g" ./cli/Cargo.toml | |
- name: Build ${{ matrix.target }} target | |
uses: ./.github/actions/build_target | |
if: "!cancelled()" | |
with: | |
target: ${{ matrix.target }} | |
profile: release-with-debug | |
- name: Install sentry-cli | |
run: curl -sL https://sentry.io/get-cli/ | sh | |
- name: Upload debug info to Sentry | |
run: sentry-cli debug-files upload --include-sources target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli.debug --org=${{ secrets.SENTRY_ORG }} --project=${{ secrets.SENTRY_PROJECT }} --auth-token=${{ secrets.SENTRY_AUTH_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.artifact-name }} | |
path: target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli | |
if-no-files-found: error | |
build_osx: | |
name: Build ${{ matrix.target }} | |
strategy: | |
matrix: | |
target: [x86_64-apple-darwin, aarch64-apple-darwin] | |
runs-on: [macos-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: ${{ matrix.target }} | |
- name: Update version | |
run: | | |
export VERSION=${{ github.event.inputs.release_tag }} | |
sed -i '' "s/0.0.0/$VERSION/g" ./cli/Cargo.toml | |
- name: Add target | |
shell: bash | |
run: rustup target add ${{ matrix.target }} | |
- name: Build ${{ matrix.target }} target | |
if: "!cancelled()" | |
# NOTE: DO NOT BUILD WORKSPACE OTHERWISE THE CLI MAY BE LINKED TO UNNECESSARY LIBRARIES | |
run: cargo build -q -p trunk-analytics-cli --profile=release-with-debug --target ${{ matrix.target }} | |
- name: Check dynamic deps | |
shell: bash | |
run: | | |
set +e | |
shared_libs="$(otool -L target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli)" | |
echo "$shared_libs" | |
if echo "$shared_libs" | grep -qi python; then | |
echo "trunk-analytics-cli has dynamic Python deps - we expect it not to be linked to Python" | |
exit 1 | |
fi | |
exit 0 | |
- name: Strip debug info | |
run: strip target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli | |
if-no-files-found: error | |
- name: Install sentry-cli | |
run: curl -sL https://sentry.io/get-cli/ | sh | |
- name: Upload debug info to Sentry | |
run: sentry-cli debug-files upload --include-sources target/${{ matrix.target }}/release-with-debug/trunk-analytics-cli.dSYM --org=${{ secrets.SENTRY_ORG }} --project=${{ secrets.SENTRY_PROJECT }} --auth-token=${{ secrets.SENTRY_AUTH_TOKEN }} | |
tag_and_release: | |
name: Tag and Release [ ${{ github.event.inputs.release_tag }} ] | |
runs-on: public-amd64-small | |
needs: [build_linux, build_osx] | |
steps: | |
- uses: actions/checkout@v4 | |
- id: download | |
uses: actions/download-artifact@v4 | |
with: | |
path: build | |
- name: Compress binaries | |
run: | | |
for target in $(ls build) | |
do | |
chmod u+x build/${target}/trunk-analytics-cli | |
tar czvf \ | |
build/trunk-analytics-cli-${target}.tar.gz \ | |
-C build/${target} trunk-analytics-cli | |
done | |
- name: Install Trunk | |
uses: trunk-io/trunk-action/install@54ccfcf9add644a36a5aa1d0046c92f654ff9e45 | |
- name: Create GH release and upload binary | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create --prerelease --latest=false \ | |
--target ${{ github.ref }} \ | |
--generate-notes ${{ github.event.inputs.release_tag }} \ | |
./build/*.tar.gz | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
version: ${{ github.event.inputs.release_tag }} |