Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test release for new build pipeline (ignore please) #1394

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
merge_group:
branches:
- main
workflow_call: {}

jobs:
build:
Expand Down
143 changes: 130 additions & 13 deletions .github/workflows/packaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,141 @@ on:
push:
branches:
- 'release/**'
- packaging-rework
tags:
- 'v**'
workflow_dispatch:

jobs:
package:
uses: pendulum-project/ploutos/.github/workflows/pkg-rust.yml@provide-debug-symbols
with:
workspace_package: ntpd
runs-on: ubuntu-latest
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
steps:
- name: Setup packaging tools for cross compiled artifacts
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2
with:
packages: qemu-user-static crossbuild-essential-armhf crossbuild-essential-arm64 crossbuild-essential-i386
version: 1

package_build_rules: |
pkg: ntpd-rs
image:
- "rockylinux:9"
- "ubuntu:xenial"
target: x86_64
- name: Install toolchain
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
with:
toolchain: "stable"
components: "llvm-tools"

package_test_scripts_path: pkg/test-scripts/test-ntpd-rs.sh
- name: Install cross, cargo-deb and cargo-generate-rpm
uses: taiki-e/install-action@4abee32ddd6d3482e57ba21814317997e6268efe
with:
tool: cross, cargo-deb, cargo-generate-rpm

rpm_scriptlets_path: pkg/rpm/scriptlets.toml
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Build the release binaries
run: RELEASE_TARGETS="${{ matrix.target }}" utils/build-release.sh

- name: Upload artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: release-binaries-${{ matrix.target }}
path: target/pkg/
if-no-files-found: error

gather:
needs: package
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
pattern: release-binaries-*
path: target/pkg/
merge-multiple: true
- name: Create a SHA256SUMS file
run: |
cd target/pkg/
rm -rf SHA256SUMS
sha256sum -b * > SHA256SUMS
- name: Upload artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: release-binaries
path: target/pkg/
if-no-files-found: error

checks:
uses: './.github/workflows/checks.yaml'

release:
needs: [gather, checks]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
permissions:
# This part of the release pipeline needs to create a tag and a release
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Download artifacts
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: release-binaries
path: target/pkg/

- name: Install toolchain
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
with:
toolchain: "stable"
components: "llvm-tools"

- name: Check that the release commit is verified
run: |
commit_url="${{ github.api_url }}/repos/${{ github.repository }}/commits/${{ github.sha }}"
json_accept_header="Accept: application/vnd.github+json"
auth_bearer_header="Authorization: Bearer ${{ github.token }}"
test "$(curl -sf -H "$json_accept_header" -H "$auth_bearer_header" "$commit_url" | jq .commit.verification.verified)" == "true"

- name: Read the version from the manifest file
run: echo "release_version=$(cargo read-manifest --manifest-path ntpd/Cargo.toml | jq -r .version)" >> "$GITHUB_ENV"

- name: Version in Cargo.toml must match the branch name
run: test "release/$release_version" == "${{ github.ref_name }}"

- name: Ensure there is not already a released tag with a non-draft release
run: test "$(gh release view "v$release_version" --json isDraft --jq .isDraft 2>/dev/null || echo "true")" == "true"

- name: Verify that the changelog top most entry concerns this release
run: |
release_notes="$(awk '/^## / && !found { found=1; print; next } /^## / && found { exit } found { print }' CHANGELOG.md)"
release_notes_header="$(echo "$release_notes" | head -1)"
echo "Found release notes for '$release_notes_header'"
release_notes_body="$(echo "$release_notes" | tail +2)"
release_notes_body="${release_notes_body#"${release_notes_body%%[![:space:]]*}"}"
release_notes_body="${release_notes_body%"${release_notes_body##*[![:space:]]}"}"
release_notes_version="$(echo "$release_notes_header" | cut -d' ' -f2 | sed 's/[][]//g')"
echo "Found version '$release_notes_version' in release notes"
test "$release_notes_version" == "${{ env.release_version }}"
{
echo "release_notes_body<<RELEASE_NOTES_EOF"
echo "$release_notes_body"
echo RELEASE_NOTES_EOF
} >> "$GITHUB_ENV"

- name: Create a draft release
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
with:
draft: true
fail_on_unmatched_files: true
tag_name: "v${{ env.release_version }}"
target_commitish: "${{ github.sha }}"
name: "Version ${{ env.release_version }}"
files: target/pkg/*
body: "${{ env.release_notes_body }}"

rpm_extra_build_packages: git
deb_extra_build_packages: git
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.1.3] - 2023-11-23

### Added
- Server can now be run without permission to change the system clock so long
as no time sources are configured.
- Experimental NTPv5 draft support was added behind a feature flag (disabled by
default)

### Changed
- The sources section can be left out of the configuration now.
- When no sources are configured, the daemon will merely state it won't change
system time, rather than warn
- The MSRV was raised to 1.67

## [1.1.2] - 2024-02-01

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]

Check notice on line 1 in Cargo.toml

View workflow job for this annotation

GitHub Actions / package / pkg (ntpd-rs, ubuntu:xenial, x86_64, --features unstable_ntpv5)

Cargo deb variant 'ubuntu-xenial' not found, using defaults instead.
members = [
"ntp-proto",
"nts-pool-ke",
Expand All @@ -12,7 +12,7 @@

# Global settings for our crates
[workspace.package]
version = "1.1.2"
version = "1.1.3"
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/pendulum-project/ntpd-rs"
Expand Down Expand Up @@ -61,4 +61,4 @@

# our own crates used as dependencies, same version as the workspace version
# NOTE: keep this part at the bottom of the file, do not change this line
ntp-proto = { version = "1.1.2", path = "./ntp-proto", features = ["__internal-api"] }
ntp-proto = { version = "1.1.3", path = "./ntp-proto", features = ["__internal-api"] }
5 changes: 5 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu"

[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu"
2 changes: 1 addition & 1 deletion docs/man/ntp-ctl.8.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- ---
title: NTP-CTL(8) ntpd-rs 1.1.2 | ntpd-rs
title: NTP-CTL(8) ntpd-rs 1.1.3 | ntpd-rs
--- -->

# NAME
Expand Down
2 changes: 1 addition & 1 deletion docs/man/ntp-daemon.8.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- ---
title: NTP-DAEMON(8) ntpd-rs 1.1.2 | ntpd-rs
title: NTP-DAEMON(8) ntpd-rs 1.1.3 | ntpd-rs
--- -->

# NAME
Expand Down
2 changes: 1 addition & 1 deletion docs/man/ntp-metrics-exporter.8.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- ---
title: NTP-METRICS-EXPORTER(8) ntpd-rs 1.1.2 | ntpd-rs
title: NTP-METRICS-EXPORTER(8) ntpd-rs 1.1.3 | ntpd-rs
--- -->

# NAME
Expand Down
2 changes: 1 addition & 1 deletion docs/man/ntp.toml.5.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- ---
title: NTP.TOML(5) ntpd-rs 1.1.2 | ntpd-rs
title: NTP.TOML(5) ntpd-rs 1.1.3 | ntpd-rs
--- -->

# NAME
Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled/man/ntp-ctl.8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "NTP-CTL" "8" "" "ntpd-rs 1.1.2" "ntpd-rs"
.TH "NTP-CTL" "8" "" "ntpd-rs 1.1.3" "ntpd-rs"
.hy
.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled/man/ntp-daemon.8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "NTP-DAEMON" "8" "" "ntpd-rs 1.1.2" "ntpd-rs"
.TH "NTP-DAEMON" "8" "" "ntpd-rs 1.1.3" "ntpd-rs"
.hy
.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled/man/ntp-metrics-exporter.8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "NTP-METRICS-EXPORTER" "8" "" "ntpd-rs 1.1.2" "ntpd-rs"
.TH "NTP-METRICS-EXPORTER" "8" "" "ntpd-rs 1.1.3" "ntpd-rs"
.hy
.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled/man/ntp.toml.5
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "NTP.TOML" "5" "" "ntpd-rs 1.1.2" "ntpd-rs"
.TH "NTP.TOML" "5" "" "ntpd-rs 1.1.3" "ntpd-rs"
.hy
.SH NAME
.PP
Expand Down
1 change: 1 addition & 0 deletions pkg/rpm/scriptlets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
# Run commands equivalent to what the RPM systemd macros would do
systemd_preun ntpd-rs.service
systemd_preun ntpd-rs-metrics.service
systemd_triggers
fi
'''
Expand Down
1 change: 1 addition & 0 deletions pkg/test-scripts/test-ntpd-rs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ case $1 in
# and configuration validates.
echo -e "\nNTPD-RS HELP OUTPUT:"
/usr/bin/ntp-daemon --help
/usr/bin/ntp-metrics-exporter --help
/usr/bin/ntp-ctl validate

# # Ensure that the systemd service is running
Expand Down
67 changes: 67 additions & 0 deletions utils/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -eo pipefail

: "${RELEASE_TARGETS:=aarch64-unknown-linux-gnu,armv7-unknown-linux-gnueabihf,x86_64-unknown-linux-gnu,i686-unknown-linux-gnu}"
IFS=',' read -r -a targets <<< "$RELEASE_TARGETS"

target_dir="target/pkg"

rm -rf "$target_dir"
mkdir -p "$target_dir"

package_version=$(cargo read-manifest --manifest-path ntpd/Cargo.toml | jq -r .version)
toolchain=$(rustup show active-toolchain | cut -d' ' -f1)
host_target=$(echo "$toolchain" | cut -d'-' -f2-)
sysroot=$(rustc --print sysroot)
llvm_tools_path="$sysroot/lib/rustlib/$host_target/bin"

echo "--- Running on toolchain '${toolchain}', make sure the llvm-tools component is installed"
echo "--- Host target is '$host_target'"

for target in "${targets[@]}"; do
dbg_sym_tar="ntpd-rs_dbg_$package_version-$target.tar.gz"

echo "--- Calling cross for building ntpd package for target '$target'"
cross build --target "$target" --package ntpd --release

echo "--- Creating separate debug symbol files for target '$target'"
(
cd "target/$target/release"
find . -maxdepth 1 -type f -executable -print0 | while IFS= read -r -d '' file; do
echo "--- Writing debug symbols from '$file' to '$file.dbg'"
"$llvm_tools_path/llvm-strip" --only-keep-debug -o "$file.dbg" "$file"
chmod -x "$file.dbg"
echo "--- Removing all symbols from binary '$file'"
"$llvm_tools_path/llvm-strip" -s "$file"
done
);

echo "--- Create tar for debug symbols"
(
cd "target/$target/release"
rm -f "$dbg_sym_tar"
find . -maxdepth 1 -type f -name '*.dbg' -exec tar uvf "$dbg_sym_tar" {} +
);

echo "--- Creating deb package"
cargo deb --no-build --no-strip --target "$target" --compress-type xz --package ntpd

echo "--- Creating rpm package"
cargo generate-rpm --payload-compress xz --package ntpd --target "$target" --target-dir target

echo "--- Copying output files to target"
cp "target/$target/release/$dbg_sym_tar" "$target_dir/"
find "target/$target/debian" -maxdepth 1 -type f -name '*.deb' -exec cp "{}" "$target_dir/" \;
find "target/$target/generate-rpm" -maxdepth 1 -type f -name '*.rpm' -exec cp "{}" "$target_dir/" \;
done

echo "--- Generating SHA256SUMS file"
(
cd $target_dir
sha256sum -b * > SHA256SUMS
)

echo "--- Done, output is in $target_dir"


Loading