Skip to content

Commit 3b0f3dc

Browse files
committed
wip: ci/publish actions
1 parent 5f2511a commit 3b0f3dc

File tree

2 files changed

+116
-4
lines changed

2 files changed

+116
-4
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ on:
77

88
jobs:
99
publish-pyroscope:
10-
name: Publish pyroscope crate
10+
name: pyroscope-lib
1111
runs-on: ubuntu-latest
12+
if: "startsWith(github.event.release.tag_name, 'lib-')"
1213
steps:
1314
- uses: actions/checkout@v1
1415
- uses: actions-rs/toolchain@v1
@@ -20,3 +21,18 @@ jobs:
2021
run: |
2122
cargo login ${{ secrets.CARGO_TOKEN }}
2223
cargo publish
24+
publish-cli:
25+
name: pyroscope-cli
26+
runs-on: ubuntu-latest
27+
if: "startsWith(github.event.release.tag_name, 'cli-')"
28+
steps:
29+
- uses: actions/checkout@v1
30+
- uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: stable
33+
override: true
34+
- name: publish pyroscope crate
35+
continue-on-error: true
36+
run: |
37+
cargo login ${{ secrets.CARGO_TOKEN }}
38+
cargo publish --manifest-path pyroscope_cli/Cargo.toml

.github/workflows/release.yml

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,109 @@ name: Pre-Release
33
on: [push]
44

55
jobs:
6-
release:
7-
name: Create draft release
6+
lib-release:
7+
name: pyroscope-main
88
runs-on: ubuntu-latest
9-
if: "startsWith(github.ref, 'refs/tags/')"
9+
if: "startsWith(github.ref, 'refs/tags/lib-')"
10+
continue-on-error: true
1011
steps:
1112
- uses: "marvinpinto/[email protected]"
1213
with:
1314
repo_token: "${{ secrets.GITHUB_TOKEN }}"
15+
automatic_release_tag: "${{ github.ref_name }}"
16+
title: "pyroscope-${{ github.ref_name }}"
1417
draft: true
1518
prerelease: false
19+
cli-release:
20+
name: pyroscope-cli
21+
runs-on: ubuntu-latest
22+
if: "startsWith(github.ref, 'refs/tags/cli-')"
23+
steps:
24+
- uses: "marvinpinto/[email protected]"
25+
with:
26+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
27+
automatic_release_tag: "${{ github.ref_name }}"
28+
title: "pyroscope-${{ github.ref_name }}"
29+
draft: true
30+
prerelease: false
31+
cli-artifacts:
32+
name: pyroscope-cli - build aritifacts
33+
needs: ['cli-release']
34+
runs-on: ${{ matrix.os }}
35+
env:
36+
# For some builds, we use cross to test on 32-bit and big-endian
37+
# systems.
38+
CARGO: cargo
39+
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
40+
TARGET_FLAGS: ""
41+
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
42+
TARGET_DIR: ./target
43+
# Emit backtraces on panics.
44+
RUST_BACKTRACE: 1
45+
strategy:
46+
matrix:
47+
build: [linux, linux-arm, macos]
48+
include:
49+
- build: linux
50+
os: ubuntu-18.04
51+
rust: stable
52+
target: x86_64-unknown-linux-musl
53+
- build: linux-arm
54+
os: ubuntu-18.04
55+
rust: stable
56+
target: arm-unknown-linux-gnueabihf
57+
- build: macos
58+
os: macos-latest
59+
rust: stable
60+
target: x86_64-apple-darwin
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v2
64+
65+
- name: Install Rust
66+
uses: actions-rs/toolchain@v1
67+
with:
68+
toolchain: ${{ matrix.rust }}
69+
profile: minimal
70+
override: true
71+
target: ${{ matrix.target }}
72+
73+
- name: Use Cross
74+
shell: bash
75+
run: |
76+
cargo install cross
77+
echo "CARGO=cross" >> $GITHUB_ENV
78+
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
79+
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
80+
81+
- name: Show command used for Cargo
82+
run: |
83+
echo "cargo command is: ${{ env.CARGO }}"
84+
echo "target flag is: ${{ env.TARGET_FLAGS }}"
85+
echo "target dir is: ${{ env.TARGET_DIR }}"
86+
87+
- name: Build release binary
88+
run: ${{ env.CARGO }} build --manifest-path pyroscope_cli/Cargo.toml --verbose --release ${{ env.TARGET_FLAGS }}
89+
90+
- name: Strip release binary (linux and macos)
91+
if: matrix.build == 'linux' || matrix.build == 'macos'
92+
run: strip "pyroscope_cli/target/${{ matrix.target }}/release/pyroscope-cli"
93+
94+
- name: Strip release binary (arm)
95+
if: matrix.build == 'linux-arm'
96+
run: |
97+
docker run --rm -v \
98+
"$PWD/target:/target:Z" \
99+
rustembedded/cross:arm-unknown-linux-gnueabihf \
100+
arm-linux-gnueabihf-strip \
101+
/target/arm-unknown-linux-gnueabihf/release/pyroscope-cli
102+
103+
- name: Upload release archive
104+
uses: actions/[email protected]
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
upload_url: ${{ needs.create-release.outputs.upload_url }}
109+
asset_path: "pyroscope_cli/target/${{ matrix.target }}/release/pyroscope-cli"
110+
asset_name: "pyroscope-cli"
111+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)