Skip to content

Commit e51410a

Browse files
chore: Add release CI (#2)
1 parent 956d7cc commit e51410a

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
name: Lint
12
on: pull_request
23

34
jobs:

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
name: Build release artifacts
11+
strategy:
12+
matrix:
13+
include:
14+
- os: ubuntu-22.04
15+
relname: x86_64-linux
16+
# uncomment when open-sourced
17+
# - os: ubuntu-22.04-arm
18+
# relname: arm64-linux
19+
- os: macos-latest
20+
relname: arm64-darwin
21+
- os: macos-15-intel
22+
relname: x86_64-darwin
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/cache@v3
27+
with:
28+
path: |
29+
~/.cargo/registry
30+
~/.cargo/git
31+
target
32+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}-1
33+
- name: Setup environment variables
34+
run: |
35+
echo "RUSTFLAGS=--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" >> $GITHUB_ENV
36+
ver="v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name=="icp-cli-network-launcher") | .version')"
37+
echo "VER=$ver" >> "$GITHUB_ENV"
38+
- name: Verify version tag
39+
if: ${{ github.ref_type == 'tag' }}
40+
run: |
41+
if [ "${GITHUB_REF_NAME}" != "${VER}" ]; then
42+
echo "Tag ${GITHUB_REF_NAME} does not match package version ${VER}"
43+
exit 1
44+
fi
45+
- name: Build and package
46+
run: ./package.sh
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
- name: Upload artifacts
50+
uses: actions/upload-artifact@v4
51+
if: ${{ github.ref_type == 'tag' }}
52+
with:
53+
name: icp-cli-network-launcher-${{ matrix.relname }}-${{ env.VER }}
54+
path: dist/icp-cli-network-launcher-${{ matrix.relname }}-${{ env.VER }}.tar.gz
55+
56+
aggregate:
57+
name: build:required
58+
runs-on: ubuntu-latest
59+
needs: build
60+
if: ${{ always() }}
61+
steps:
62+
- if: ${{ needs.build.result != 'success' }}
63+
run: exit 1
64+
65+
release:
66+
name: Create release
67+
if: ${{ github.ref_type == 'tag' }}
68+
needs: build
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
# relname: [x86_64-linux, arm64-linux, arm64-darwin, x86_64-darwin]
73+
relname: [x86_64-linux, arm64-darwin, x86_64-darwin]
74+
steps:
75+
- name: Download build artifacts
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: icp-cli-network-launcher-${{ matrix.relname }}-${{ github.ref_name }}
79+
- name: Upload tarball and sha256
80+
uses: svenstaro/upload-release-action@v2
81+
with:
82+
repo_token: ${{ secrets.GITHUB_TOKEN }}
83+
file: icp-*.tar.*
84+
file_glob: true
85+
tag: ${{ github.ref_name }}
86+
prerelease: true
87+
make_latest: false

package.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ if [[ "$v" = *"+"* ]]; then
2828
else
2929
[[ "$source" != "git+"* ]] || die "package.version is not patch but pocket-ic dependency is git"
3030
fi
31-
name="icp-cli-network-launcher-${arch}-${os}-${v}"
31+
name="icp-cli-network-launcher-${arch}-${os}-v${v}"
3232
outdir="${1-"dist/${name}"}"
3333

3434
cargo build --release
3535
mkdir -p "${outdir}"
3636
cp "target/release/icp-cli-network-launcher" "${outdir}/"
3737
if [[ -z "$sha" ]]; then
38-
curl --proto '=https' -sSfL --tlsv1.2 "https://github.com/dfinity/pocketic/releases/download/${v}/pocket-ic-${arch}-${os}.gz" -o "${outdir}/pocket-ic.gz"
38+
curl --proto '=https' -sSfL --tlsv1.2 "https://github.com/dfinity/pocketic/releases/download/${v}/pocket-ic-${arch}-${os}.gz" -o "${outdir}/pocket-ic.gz" ${GITHUB_TOKEN:+ -H "Authorization: Bearer ${GITHUB_TOKEN}" }
3939
else
4040
curl --proto '=https' -sSfL --tlsv1.2 "https://download.dfinity.systems/ic/${sha}/binaries/${arch}-${os}/pocket-ic.gz" -o "${outdir}/pocket-ic.gz"
4141
fi

0 commit comments

Comments
 (0)