Skip to content
Snippets Groups Projects
Commit 439c267c authored by poka's avatar poka
Browse files

build macos packages in CI

parent 9365b805
No related branches found
No related tags found
No related merge requests found
Pipeline #37108 passed
[target.x86_64-apple-darwin]
linker = "o64-clang"
rustflags = [
"-C",
"link-arg=-mmacosx-version-min=10.12",
"-C",
"target-feature=+crt-static",
]
# Official language image. Look for the different tagged releases at: # Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/rust/tags/ # https://hub.docker.com/r/library/rust/tags/
image: "rust:latest"
stages: stages:
- build_and_package - build_linux
- build_macos
- release - release
build_and_package: build_linux:
stage: build_and_package stage: build_linux
image: rust:slim-buster image: rust:slim-buster
script: script:
# Build the project # Build the project for Linux
- cargo build --release - cargo build --release
# Install cargo-deb
- cargo install cargo-deb
# Create Debian package # Create Debian package
- cargo install cargo-deb
- cargo deb --no-build - cargo deb --no-build
- ls target/debian/*.deb | head -n 1 > debian_package.txt - ls target/debian/*.deb | head -n 1 > debian_package.txt
artifacts: artifacts:
...@@ -24,15 +22,40 @@ build_and_package: ...@@ -24,15 +22,40 @@ build_and_package:
- target/debian/*.deb - target/debian/*.deb
- debian_package.txt - debian_package.txt
cache: cache:
key: key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
files:
- Cargo.lock
paths: paths:
- target/release - target/release
- target/debian - target/debian
only: only:
- tags - tags
build_macos:
stage: build_macos
image: poka/rust-osxcross:1.0.2
script:
# Install the required dependencies
- rustup target add x86_64-apple-darwin
# Build the project for macOS
- cargo build --release --target x86_64-apple-darwin
# Create the macOS bundle
- rm -rf target/macos
- mkdir -p target/macos
- cargo bundle --release --target x86_64-apple-darwin
# Zip the gcli.app before moving it
- cd target/x86_64-apple-darwin/release/bundle/osx
- echo -e "Unzip gcli.zip and move the gcli.app folder to /Applications/ folder.\nenjoy" > instructions.txt
- zip -r gcli.zip gcli.app instructions.txt
- mv gcli.zip ../../../../macos/ # target/macos/
artifacts:
paths:
- target/macos
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- target/macos
only:
- tags
release: release:
stage: release stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest image: registry.gitlab.com/gitlab-org/release-cli:latest
...@@ -42,26 +65,23 @@ release: ...@@ -42,26 +65,23 @@ release:
- git fetch --tags - git fetch --tags
- LAST_VERSION=$(git tag --sort=-v:refname | sed -n '2p') - LAST_VERSION=$(git tag --sort=-v:refname | sed -n '2p')
- git log --pretty="format:- %s ([%h]($CI_PROJECT_URL/-/commit/%h)) " HEAD...$LAST_VERSION --reverse > release_description.txt - git log --pretty="format:- %s ([%h]($CI_PROJECT_URL/-/commit/%h)) " HEAD...$LAST_VERSION --reverse > release_description.txt
# Define release parameters
release: release:
# Release name and description using the tag name
name: "v$CI_COMMIT_TAG" name: "v$CI_COMMIT_TAG"
description: "Latest changes:\n$(cat release_description.txt)" description: "Latest changes:\n$(cat release_description.txt)"
# Set the tag for the release
tag_name: "$CI_COMMIT_TAG" tag_name: "$CI_COMMIT_TAG"
# Attach the artifact to the release
assets: assets:
links: links:
- name: "gcli v$CI_COMMIT_TAG for Linux (binary)" - name: "gcli v$CI_COMMIT_TAG for Linux (binary)"
url: "$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/target/release/gcli?job=build_and_package" url: "$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/target/release/gcli?job=build_linux"
- name: "gcli v$CI_COMMIT_TAG Debian Package" - name: "gcli v$CI_COMMIT_TAG Debian Package"
url: "$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/$(cat debian_package.txt)?job=build_and_package" url: "$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/$(cat debian_package.txt)?job=build_linux"
# Trigger release creation only for tagged commits - name: "gcli v$CI_COMMIT_TAG for macOS"
url: "$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/target/macos/gcli.zip?job=build_macos"
only: only:
- tags - tags
# Not necessary but clearly shows the dependency
dependencies: dependencies:
- build_and_package - build_linux
- build_macos
artifacts: artifacts:
paths: paths:
- debian_package.txt - debian_package.txt
...@@ -2092,7 +2092,7 @@ dependencies = [ ...@@ -2092,7 +2092,7 @@ dependencies = [
[[package]] [[package]]
name = "gcli" name = "gcli"
version = "0.2.11" version = "0.2.12"
dependencies = [ dependencies = [
"age", "age",
"anyhow", "anyhow",
......
...@@ -9,7 +9,8 @@ rust-version = "1.75.0" ...@@ -9,7 +9,8 @@ rust-version = "1.75.0"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
name = "gcli" name = "gcli"
repository = "https://git.duniter.org/clients/rust/gcli-v2s" repository = "https://git.duniter.org/clients/rust/gcli-v2s"
version = "0.2.11" description = "A command-line interface for Duniter v2s uses"
version = "0.2.12"
[dependencies] [dependencies]
# subxt is main dependency # subxt is main dependency
...@@ -58,3 +59,8 @@ default = ["gdev"] # default runtime is "gdev", gdev network is available ...@@ -58,3 +59,8 @@ default = ["gdev"] # default runtime is "gdev", gdev network is available
gdev = [] gdev = []
gtest = [] gtest = []
g1 = [] g1 = []
[package.metadata.bundle]
name = "gcli"
identifier = "com.axiomteam.gcli"
icon = ["gcli.png"]
# Stage 1: Build environment with all dependencies
FROM rust:slim-bookworm as builder
# Install necessary dependencies
RUN apt-get update && apt-get install -y \
clang \
llvm \
make \
file \
git \
curl \
cmake \
python3 \
python3-dev \
python3-pip
# Clone osxcross repository and set up
RUN git clone https://github.com/tpoechtrager/osxcross.git /opt/osxcross && \
cd /opt/osxcross && \
./tools/get_dependencies.sh && \
cd /opt/osxcross/tarballs && \
curl -LO https://github.com/joseluisq/macosx-sdks/releases/download/10.12/MacOSX10.12.sdk.tar.xz && \
cd /opt/osxcross && \
UNATTENDED=yes ./build.sh
# Stage 2: Create the final image with only the necessary files
FROM rust:slim-bookworm
# Install cargo-bundle
RUN cargo install cargo-bundle
RUN apt-get update && apt-get install -y --no-install-recommends clang zip; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
# Copy cargo plugins from the builder stage
COPY --from=builder /opt/osxcross/target /opt/osxcross/target
# Set environment variables for osxcross and Rust
ENV PATH="/opt/osxcross/target/bin:/usr/local/cargo/bin:$PATH"
ENV CC="o64-clang"
ENV CXX="o64-clang++"
# Add rust target for macOS
RUN rustup target add x86_64-apple-darwin
# Define the entrypoint
CMD ["bash"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment