Skip to content

Commit

Permalink
Add circleci job for cross platform builds and uploading release arti…
Browse files Browse the repository at this point in the history
…facts

Signed-off-by: Yoriyasu Yano <[email protected]>
  • Loading branch information
yorinasub17 committed Nov 16, 2023
1 parent 96ab1a4 commit ca0dcbe
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 2 deletions.
126 changes: 125 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,66 @@ workflows:
lint-test-release:
jobs:
- lint-test
- build-unix:
name: build-linux-amd64
os: linux
artifactname: senc-linux-amd64.tar.gz
filters:
branches:
only:
- main
- build-unix:
name: build-linux-arm64
os: linuxarm
artifactname: senc-linux-arm64.tar.gz
filters:
branches:
only:
- main
- build-windows-amd64:
filters:
branches:
only:
- main

# NOTE:
# The darwin-arm64 build is temporarily disabled since we don't have access to the M1 environment.
# This environment will be accessible starting May 2024.
# - build-unix:
# name: build-darwin-arm64
# os: macos
# artifactname: senc-darwin-arm64.tar.gz
# filters:
# branches:
# only:
# - main

- release:
context: 'Fensak CI/CD'
requires:
- lint-test
- build-linux-amd64
- build-linux-arm64
- build-windows-amd64
# - build-darwin-arm64
filters:
branches:
only:
- main

executors:
linux:
docker:
- image: cimg/rust:1.73
linuxarm:
docker:
- image: cimg/rust:1.73
resource_class: arm.large
macos:
# https://circleci.com/docs/using-macos/
macos:
xcode: 15.0.0
resource_class: macos.m1.medium.gen1

jobs:
lint-test:
docker:
Expand Down Expand Up @@ -44,10 +95,83 @@ jobs:
name: cargo test
command: cargo test

build-windows-amd64:
machine:
image: windows-server-2022-gui:current
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
environment:
PYTHON: 'C:\Python311\python'
steps:
- add_ssh_keys:
fingerprints:
- "8f:1a:b4:37:9c:ca:cf:49:04:e7:ce:0d:b5:ee:2a:0d"
- checkout
- run:
name: setup build env
command: |
# Switch from gnu targeted rust to msvc targeted rust
choco uninstall -y rust
choco install -y rust-ms
- run:
name: build senc
command: |
cargo build --release
- run:
name: package build artifact
command: |
New-Item -Name ".build" -Type Directory
New-Item -Name ".build\prepartifact" -Type Directory
New-Item -Name ".build\artifact" -Type Directory
Copy-Item -Path "target\release\senc" -Destination ".build\prepartifact"
Copy-Item -Path "LICENSE" -Destination ".build\prepartifact"
Set-Location -Path ".build\prepartifact"
tar -zcf "..\artifact\senc-windows-amd64-msvc.tar.gz" *
- persist_to_workspace:
root: .build/artifact
paths:
- senc-windows-amd64-msvc.tar.gz

build-unix:
parameters:
os:
type: executor
artifactname:
type: string
executor: << parameters.os >>
steps:
- add_ssh_keys:
fingerprints:
- "8f:1a:b4:37:9c:ca:cf:49:04:e7:ce:0d:b5:ee:2a:0d"
- checkout
- run:
name: build senc
command: |
cargo build --release
- run:
name: package build artifact
command: |
mkdir -p ./.build/prepartifact
mkdir -p ./.build/artifact
cp target/release/senc ./.build/prepartifact
cp LICENSE ./.build/prepartifact
cd ./.build/prepartifact
tar -zcf ../artifact/<< parameters.artifactname >> *
- persist_to_workspace:
root: .build/artifact
paths:
- << parameters.artifactname >>

release:
docker:
- image: cimg/node:lts
steps:
- attach_workspace:
at: /tmp/artifact
- run:
command: |
ls -lah /tmp/artifact
- add_ssh_keys:
fingerprints:
- "8f:1a:b4:37:9c:ca:cf:49:04:e7:ce:0d:b5:ee:2a:0d"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
TODO

/target
/generated

Expand Down
3 changes: 2 additions & 1 deletion .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ plugins:
- - "@semantic-release/git"
- assets: ["Cargo.toml", "Cargo.lock"]
message: "release: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
- "@semantic-release/github"
- - "@semantic-release/github"
- assets: ["/tmp/artifact/*"]

0 comments on commit ca0dcbe

Please sign in to comment.