Skip to content

Commit cb7bdef

Browse files
authored
CI: release just a single binary (#1179)
Previously, this repo was publishing Docker container `fluencelabs/fluence`. Now, it would only publish `particle-node` binary and delegate all the Docker publishing to `fluencelabs/node-distro` repository.
1 parent 99ab6fc commit cb7bdef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+453
-1160
lines changed

.circleci/config.yml

+51-62
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ orbs:
44
docker: circleci/[email protected]
55

66
jobs:
7-
Build:
7+
Publish Branch Binary:
88
docker:
99
- image: circleci/rust:latest
1010
resource_class: xlarge
1111
environment:
1212
RUST_BACKTRACE: 1
1313
steps:
14+
- run: |
15+
if [ "$CIRCLE_BRANCH" = "master" ]; then
16+
echo "export BRANCH=''" >> $BASH_ENV
17+
else
18+
echo "export BRANCH=$CIRCLE_BRANCH" >> $BASH_ENV
19+
fi
1420
- checkout
1521
- restore_cache:
1622
keys:
@@ -19,17 +25,43 @@ jobs:
1925
rustup toolchain install nightly-2021-06-14-x86_64-unknown-linux-gnu
2026
rustup override set nightly-2021-06-14-x86_64-unknown-linux-gnu
2127
cargo build --release --all-features
22-
- persist_to_workspace:
23-
# Must be an absolute path, or relative path from working_directory.
24-
# This is a directory on the container which is taken to be the root directory of the workspace.
25-
root: .
26-
# Must be relative path from root
27-
paths:
28-
- .dockerignore
29-
- Dockerfile
30-
- target/release/particle-node
31-
- deploy/Config.default.toml
32-
- deploy/builtins
28+
- store_artifacts:
29+
path: ./target/release/particle-node
30+
- run:
31+
name: Trigger Binary Publish
32+
command: |
33+
ARTIFACTS=$(curl -X GET "https://circleci.com/api/v2/project/github/fluencelabs/fluence/$CIRCLE_BUILD_NUM/artifacts" \
34+
-H "Accept: application/json" \
35+
-u "$CIRCLE_API_TOKEN:")
36+
37+
BINARY=$(echo "$ARTIFACTS" | jq -r ".items | .[] | select(.path == \"target/release/particle-node\") | \"\(.url)\"")
38+
SHA256=$(sha256sum ./target/release/particle-node | awk '{ print $1 }')
39+
40+
OUTPUT_FILE=$(mktemp)
41+
HTTP_CODE=$(curl \
42+
--silent \
43+
--output $OUTPUT_FILE \
44+
--write-out "%{http_code}" \
45+
-u folex:${GITHUB_PERSONAL_TOKEN} \
46+
-X POST \
47+
-H "Accept: application/vnd.github.v3+json" \
48+
https://api.github.com/repos/fluencelabs/node-distro/actions/workflows/container.yml/dispatches \
49+
-d '{
50+
"ref":"container_branch",
51+
"inputs": {
52+
"container_tag":"'${BRANCH}'",
53+
"version": "'${CIRCLE_BRANCH}_${CIRCLE_SHA1}'",
54+
"url": "'${BINARY}'",
55+
"sha256": "'${SHA256}'"
56+
}
57+
}'
58+
)
59+
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
60+
>&2 cat $OUTPUT_FILE
61+
exit 22
62+
fi
63+
cat $OUTPUT_FILE
64+
rm $OUTPUT_FILE
3365
- save_cache:
3466
paths:
3567
- ~/.cargo
@@ -44,62 +76,19 @@ jobs:
4476
RUST_BACKTRACE: 1
4577
steps:
4678
- checkout
47-
- attach_workspace:
48-
at: .
4979
- run: |
5080
rustup override set nightly-2021-06-14-x86_64-unknown-linux-gnu
5181
cargo test --no-fail-fast --release --all-features
5282
53-
Publish Docker Container:
54-
executor: docker/docker
55-
resource_class: xlarge
56-
steps:
57-
- attach_workspace:
58-
at: .
59-
- setup_remote_docker
60-
- docker/check:
61-
docker-password: DOCKERHUB_TOKEN
62-
docker-username: DOCKERHUB_USERNAME
63-
64-
- run: |
65-
if [ "$CIRCLE_BRANCH" = "master" ]; then
66-
echo "export DOCKER_TAG=latest" >> $BASH_ENV
67-
echo "export BRANCH=''" >> $BASH_ENV
68-
else
69-
echo "export DOCKER_TAG=$CIRCLE_BRANCH" >> $BASH_ENV
70-
echo "export BRANCH=$CIRCLE_BRANCH" >> $BASH_ENV
71-
fi
72-
73-
- docker/build:
74-
image: fluencelabs/fluence
75-
tag: ${DOCKER_TAG},${CIRCLE_BRANCH}_${CIRCLE_SHA1}
76-
extra_build_args: --build-arg exe=./target/release/particle-node --build-arg config=./deploy/Config.default.toml --build-arg builtins=./deploy/builtins/
77-
- docker/push:
78-
image: fluencelabs/fluence
79-
tag: ${DOCKER_TAG},${CIRCLE_BRANCH}_${CIRCLE_SHA1}
80-
- run: |
81-
curl --fail \
82-
-u folex:${GITHUB_PERSONAL_TOKEN} \
83-
-X POST \
84-
-H "Accept: application/vnd.github.v3+json" \
85-
https://api.github.com/repos/fluencelabs/node-distro/actions/workflows/container.yml/dispatches \
86-
-d '{
87-
"ref":"main",
88-
"inputs": {
89-
"fluence_branch":"'${BRANCH}'"
90-
}
91-
}'
92-
93-
9483
workflows:
9584
version: 2
9685
CircleCI:
9786
jobs:
98-
- Build
99-
- Rust Tests:
100-
requires:
101-
- Build
102-
- Publish Docker Container:
103-
requires:
104-
- Build
87+
- Publish Branch Binary:
10588
context: Github Actions
89+
filters:
90+
branches:
91+
ignore:
92+
- master
93+
- main
94+
- Rust Tests
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"template": "${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
3+
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
4+
"empty_template": "- no changes"
5+
}

.github/workflows/release.yml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: "publish-release"
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
npm-publish:
10+
name: "Publish"
11+
runs-on: ubuntu-latest
12+
container: rust
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
steps:
18+
### Setup
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Set env
23+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
24+
25+
- uses: actions/cache@v2
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
31+
32+
- name: Install toolchain
33+
uses: actions-rs/toolchain@v1
34+
with:
35+
profile: minimal
36+
toolchain: nightly-2021-06-14
37+
override: true
38+
39+
### Build
40+
- name: Set version in particle-node/Cargo.toml to ${{ env.RELEASE_VERSION }}
41+
run: |
42+
VERSION=$(echo ${{ env.RELEASE_VERSION }} | tr -d v)
43+
sed -i 's/^version = ".*"/version = "'${VERSION}'"/' ./particle-node/Cargo.toml
44+
45+
- name: Build particle-node
46+
uses: actions-rs/cargo@v1
47+
with:
48+
command: build
49+
args: --release -p particle-node
50+
51+
### Release
52+
- name: Calculate SHA256
53+
run: |
54+
BINARY="./target/release/particle-node"
55+
du -hs $BINARY
56+
echo $(sha256sum $BINARY)
57+
echo "SHA256=$(sha256sum $BINARY | awk '{ print $1 }')" >> $GITHUB_ENV
58+
59+
- name: Build Changelog
60+
id: changelog
61+
uses: mikepenz/release-changelog-builder-action@v1
62+
with:
63+
configuration: ".github/workflows/changelog_config.json"
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Release
68+
id: release
69+
uses: softprops/action-gh-release@v1
70+
with:
71+
name: Fluence Node ${{ env.RELEASE_VERSION }}
72+
tag_name: ${{ env.RELEASE_VERSION }}
73+
files: |
74+
./target/release/particle-node
75+
body: |
76+
${{ steps.changelog.outputs.changelog }}
77+
78+
79+
sha256: ${{ env.SHA256 }}
80+
draft: false
81+
prerelease: false
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
85+
### Update version in node-distro
86+
- name: Get binary URL
87+
id: package-url
88+
uses: actions/github-script@v4
89+
with:
90+
github-token: ${{ secrets.GITHUB_TOKEN }}
91+
result-encoding: string
92+
script: |
93+
try {
94+
let assets = await github.repos.listReleaseAssets({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
release_id: "${{ steps.release.outputs.id }}",
98+
});
99+
console.dir(assets);
100+
let package = assets.data.find((a) => a.name === 'particle-node');
101+
let url = package.browser_download_url;
102+
console.log("URL: " + url);
103+
return url;
104+
} catch (e) {
105+
console.log("Err: " + e);
106+
throw e;
107+
}
108+
109+
- name: Update version in node-distro
110+
uses: benc-uk/workflow-dispatch@v1
111+
with:
112+
workflow: update_fluence
113+
repo: fluencelabs/node-distro
114+
ref: 'services_json'
115+
token: ${{ secrets.PERSONAL_TOKEN }}
116+
inputs: '{
117+
"version": "${{ env.RELEASE_VERSION }}",
118+
"url": "${{ steps.package-url.outputs.result }}",
119+
"sha256": "${{ env.SHA256 }}"
120+
}'

.github/workflows/tag.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "tag"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
tag:
8+
name: "Tag"
9+
runs-on: "ubuntu-latest"
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Bump version and push tag
14+
id: tag_version
15+
uses: mathieudutour/[email protected]
16+
with:
17+
github_token: ${{ secrets.PERSONAL_TOKEN }}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ dist
104104
# TernJS port file
105105
.tern-port
106106

107-
108107
.fluence/
109108
target/
110109
**/target/
111110
**/*.rs.bk
112111
.idea
113112
.DS_Store
114113
*.iml
115-
**/*.iml
114+
**/*.iml
115+
cargo-timing*

Cargo.lock

+30-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ members = [
2525
"crates/toy-vms",
2626
"crates/connected-client",
2727
"crates/test-constants",
28+
"particle-node/tests/builtins",
2829
"particle-node",
2930
"aquamarine",
3031
"particle-protocol",

Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test:
99

1010
server:
1111
RUST_LOG="info,tide=off" \
12-
cargo +nightly run --release -p particle-node -- -c ./deploy/Config.default.toml
12+
cargo +nightly run --release -p particle-node
1313

1414
server-debug:
1515
RUST_LOG="debug,\
@@ -36,8 +36,4 @@ server-debug:
3636
polling=info" \
3737
cargo +nightly run --release -p particle-node -- -c ./deploy/Config.default.toml
3838

39-
# deploy existing containers (configure tag in deployment_config.json)
40-
deploy:
41-
cd deploy; fab deploy_fluence
42-
4339
.PHONY: server server-debug test release build deploy

aquamarine/src/vm_pool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<RT: AquaRuntime> VmPool<RT> {
8888
// Remove completed future
8989
creating_vms.remove(i);
9090
if creating_vms.is_empty() {
91-
log::info!("All stepper VMs created.")
91+
log::info!("All {} AquaVMs created.", self.pool_size)
9292
}
9393

9494
// Put created vm to self.vms

0 commit comments

Comments
 (0)