Skip to content

Commit

Permalink
Remove unnecessary volume mount from local build command in README.md…
Browse files Browse the repository at this point in the history
…; move `cross` config in Cargo.toml; use run-on-arch-action for x86 and ARM; remove build job container directive; reformat ci comments

Revert actions/checkout to v2

use run-on-arch-action for x86 and ARM; remove build job container directive; reformat ci comments
  • Loading branch information
xenago committed Jun 1, 2024
1 parent 5213573 commit 7988dc9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 40 deletions.
100 changes: 63 additions & 37 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ on:

jobs:
build:
name: build
name: build and release
runs-on: ubuntu-20.04
container: quay.io/pypa/manylinux2014_x86_64 # Use a container with glibc 2.17
steps:

- name: Checkout # Clone repository
uses: actions/checkout@v4
uses: actions/checkout@v2
with:
fetch-depth: 0

Expand All @@ -23,64 +22,91 @@ jobs:
export VERSION=${{github.ref_name}}
sed -i "s/0.0.0/$VERSION/g" Cargo.toml
- name: Install stable toolchain # Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Cargo build # Build for release
run: |
cargo build --release --verbose
ls -lah target/release
- name: Cargo deb # Package deb
run: |
cargo install --version 1.44.1 cargo-deb
cargo deb --no-build --verbose
ls -lah target/debian
- name: Cargo rpm # Package RPM
run: |
cargo install --version 0.14.0 cargo-generate-rpm
strip -s target/release/libnss_shim.so
cargo generate-rpm --payload-compress none
ls -lah target/generate-rpm
# - name: Install stable toolchain # Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
#
# - name: Cargo build # Build for release
# run: |
# cargo build --release --verbose
# ls -lah target/release
#
# - name: Cargo deb # Package deb
# run: |
# cargo install --version 1.44.1 cargo-deb
# cargo deb --no-build --verbose
# ls -lah target/debian
#
# - name: Cargo rpm # Package RPM
# run: |
# cargo install --version 0.14.0 cargo-generate-rpm
# strip -s target/release/libnss_shim.so
# cargo generate-rpm --payload-compress none
# ls -lah target/generate-rpm

- uses: uraimo/run-on-arch-action@v2 # Cross-build (arm64/aarch64)
name: Cross-build (arm64/aarch64)
# Build for AMD64
- uses: uraimo/run-on-arch-action@v2
name: x86 Build (x86_64/amd64)
with:
base_image: quay.io/pypa/manylinux2014_aarch64
# Use a container with glibc 2.17
base_image: quay.io/pypa/manylinux2014_x86_64
env: |
VERSION: ${{github.ref_name}}
# Mount the working directory as /libnss_shim in the container, and run commands there
dockerRunArgs: |
--volume "${PWD}:/libnss_shim"
-w "/libnss_shim"
# Speeds up builds
# Speeds up builds, intermediate containers are cached publicly
githubToken: ${{ github.token }}
# Prepare cached dependencies
setup: |
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
cargo install --version 1.44.1 cargo-deb
cargo install --version 0.14.0 cargo-generate-rpm
cargo build --release --verbose
ls -lah target/release
strip -s target/release/libnss_shim.so
ls -lah target/release
cargo deb --no-build --verbose
ls -lah target/debian
cargo generate-rpm --payload-compress none
ls -lah target/generate-rpm
# Build for arm64/aarch64 by emulating in QEMU
- uses: uraimo/run-on-arch-action@v2
name: QEMU ARM build (arm64/aarch64)
with:
base_image: quay.io/pypa/manylinux2014_aarch64
env: |
VERSION: ${{github.ref_name}}
dockerRunArgs: |
--volume "${PWD}:/libnss_shim"
-w "/libnss_shim"
githubToken: ${{ github.token }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
cargo install --version 1.44.1 cargo-deb
cargo install --version 0.14.0 cargo-generate-rpm
cargo build --release --verbose
ls -lah target/release
cargo deb --no-build --verbose
ls -lah target/debian
cargo generate-rpm --payload-compress none
ls -lah target/generate-rpm
- name: Release # Publish GitHub release
# Publish GitHub release
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') # Presumably redundant due to the `on: push: tags:` filter, but kept for safety
# Presumably redundant due to the `on: push: tags:` filter, but kept for safety
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{github.workspace}}/changelog/CHANGELOG.txt # Add the release notes from the changelog file
fail_on_unmatched_files: true # Ensure all packages built, to avoid publishing an incomplete release
# Add the release notes from the changelog file
body_path: ${{github.workspace}}/changelog/CHANGELOG.txt
fail_on_unmatched_files: true
files: |
target/debian/*.deb
target/generate-rpm/*.rpm
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ assets = [
]
post_install_script = "debian/postinst"
post_uninstall_script = "debian/postrm"

# Required by `cross` tool for glibc 2.17 CentOS-compatible cross-compilation
[workspace.metadata.cross.target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main-centos"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ I generally find it easiest to run `build.sh` inside a temporary container:

3. Run the build script inside a temporary container, setting `LIBNSS_SHIM_VERSION` and the cloned repo path as desired:

sudo docker run -e "LIBNSS_SHIM_VERSION=0.0.0" -v /path/to/cloned/libnss_shim:/libnss_shim -v /var/run/docker.sock:/var/run/docker.sock --rm -it quay.io/pypa/manylinux2014_x86_64:latest bash /libnss_shim/build.sh
sudo docker run -e "LIBNSS_SHIM_VERSION=0.0.0" -v /path/to/cloned/libnss_shim:/libnss_shim --rm -it quay.io/pypa/manylinux2014_x86_64:latest bash /libnss_shim/build.sh

Note that this requires
Note: [the `manylinux2014` container](https://github.com/pypa/manylinux) is available for various architectures.

4. The build script will output packages in the following subdirectories of the cloned repo:

Expand Down
3 changes: 2 additions & 1 deletion changelog/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
- Required change: 64-bit integer types to platform-dependent `size` pointer types
- Remove `lazy_static` dependency
- Add additional resource, update formatting of `README.md`
- Bump toolchain to 1.78.0
- Bump rust toolchain to `1.78.0`
- Add ARM compile step to CI
- Use `uraimo/run-on-arch` action for building
- Adjust README.md to clarify install/upgrade are the same process
- Add RPM uninstall notes to README.md
- Add find-requires script for build (not yet implemented)

0 comments on commit 7988dc9

Please sign in to comment.