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

feat: Automate Release #165

Merged
merged 13 commits into from
Apr 17, 2024
Merged
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
10 changes: 0 additions & 10 deletions .github/workflows/enforce-linking-issues.yml

This file was deleted.

115 changes: 101 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,62 @@
name: Release

on:
release:
types: [published]
schedule:
- cron: "0 1 * * 1-5"
workflow_dispatch:
inputs:
live-run:
type: boolean
description: Live-run
required: false
version:
type: string
description: Release number
required: false
zenoh-version:
type: string
description: Release number of Zenoh
required: false

jobs:
macos:
tag:
name: Branch, Bump & tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create-release-branch.outputs.version }}
branch: ${{ steps.create-release-branch.outputs.branch }}
steps:
- id: create-release-branch
uses: eclipse-zenoh/ci/create-release-branch@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ inputs.version }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ steps.create-release-branch.outputs.branch }}

- name: Bump and tag project
run: bash ci/scripts/bump-and-tag.bash
env:
VERSION: ${{ steps.create-release-branch.outputs.version }}
BUMP_DEPS_VERSION: ${{ inputs.zenoh-version }}
BUMP_DEPS_PATTERN: ${{ inputs.zenoh-version && 'zenoh.*' || '' }}
BUMP_DEPS_BRANCH: ${{ inputs.zenoh-version && format('release/{0}', inputs.zenoh-version) || '' }}
GIT_USER_NAME: eclipse-zenoh-bot
GIT_USER_EMAIL: eclipse-zenoh-bot@users.noreply.github.com

build-macos:
needs: tag
runs-on: macos-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}

- name: Install Rust toolchain
run: |
Expand All @@ -36,7 +80,8 @@ jobs:
name: wheels
path: dist

windows:
build-windows:
needs: tag
runs-on: windows-latest
strategy:
matrix:
Expand All @@ -45,6 +90,8 @@ jobs:
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}

- name: Install Rust toolchain
run: |
Expand All @@ -63,14 +110,17 @@ jobs:
name: wheels
path: dist

linux:
build-linux:
needs: tag
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, i686, armv7]
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}

- name: Build wheels
uses: messense/maturin-action@v1
Expand All @@ -85,11 +135,14 @@ jobs:
name: wheels
path: dist

linux-aarch64:
build-linux-aarch64:
needs: tag
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}

- name: Build wheels
uses: messense/maturin-action@v1
Expand All @@ -110,18 +163,21 @@ jobs:
name: wheels
path: dist

linux-armv6:
build-linux-armv6:
needs: tag
runs-on: macos-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}

- name: Install Rust toolchain
run: |
rustup set profile minimal
rustup target add arm-unknown-linux-gnueabihf

- name: install cross toolchain
- name: Install cross toolchain
run: |
brew tap messense/macos-cross-toolchains
brew install arm-unknown-linux-gnueabihf
Expand All @@ -140,19 +196,50 @@ jobs:
name: wheels
path: dist

deploy-wheels:
needs: [macos, windows, linux, linux-armv6]
name: deploy wheels to pypi
publish-pypi:
needs:
[
tag,
build-macos,
build-windows,
build-linux,
build-linux-armv6,
build-linux-aarch64,
]
name: Deploy wheels to pypi
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist

- name: Check dist
run: ls -al ./dist/*
- name: publish
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.6.4

- name: Publish
if: ${{ inputs.live-run || false }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ORG_TOKEN }}

publish-github:
needs:
[
tag,
build-macos,
build-windows,
build-linux,
build-linux-armv6,
build-linux-aarch64,
]
runs-on: ubuntu-latest
steps:
- uses: eclipse-zenoh/ci/publish-crates-github@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
archive-patterns: "^$"
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sphinx:
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.11"
rust: "latest"
jobs:
pre_build:
Expand Down
66 changes: 66 additions & 0 deletions ci/scripts/bump-and-tag.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

set -xeo pipefail

# Release number
readonly version=${VERSION:?input VERSION is required}
# Dependencies' pattern
readonly bump_deps_pattern=${BUMP_DEPS_PATTERN:-''}
# Dependencies' version
readonly bump_deps_version=${BUMP_DEPS_VERSION:-''}
# Dependencies' git branch
readonly bump_deps_branch=${BUMP_DEPS_BRANCH:-''}
# Git actor name
readonly git_user_name=${GIT_USER_NAME:?input GIT_USER_NAME is required}
# Git actor email
readonly git_user_email=${GIT_USER_EMAIL:?input GIT_USER_EMAIL is required}

cargo +stable install toml-cli

# NOTE(fuzzypixelz): toml-cli doesn't yet support in-place modification
# See: https://github.com/gnprice/toml-cli?tab=readme-ov-file#writing-ish-toml-set
function toml_set_in_place() {
local tmp=$(mktemp)
toml set "$1" "$2" "$3" > "$tmp"
mv "$tmp" "$1"
}

export GIT_AUTHOR_NAME=$git_user_name
export GIT_AUTHOR_EMAIL=$git_user_email
export GIT_COMMITTER_NAME=$git_user_name
export GIT_COMMITTER_EMAIL=$git_user_email

# Bump Cargo version
toml_set_in_place Cargo.toml "package.version" "$version"
# Propagate version change to pyproject.toml
toml_set_in_place pyproject.toml "project.version" "$version"

git commit Cargo.toml pyproject.toml -m "chore: Bump version to $version"

# Select all package dependencies that match $bump_deps_pattern and bump them to $bump_deps_version
if [[ "$bump_deps_pattern" != '' ]]; then
deps=$(toml get Cargo.toml dependencies | jq -r "keys[] | select(test(\"$bump_deps_pattern\"))")
for dep in $deps; do
if [[ -n $bump_deps_version ]]; then
toml_set_in_place Cargo.toml "dependencies.$dep.version" "$bump_deps_version"
fi

if [[ -n $bump_deps_branch ]]; then
toml_set_in_place Cargo.toml "dependencies.$dep.branch" "$bump_deps_branch"
fi
done
# Update lockfile
cargo check

if [[ -n $bump_deps_version || -n $bump_deps_branch ]]; then
git commit Cargo.toml Cargo.lock -m "chore: Bump $bump_deps_pattern version to $bump_deps_version"
else
echo "warn: no changes have been made to any dependencies matching $bump_deps_pattern"
fi
fi

git tag --force "$version" -m "v$version"
git log -10
git show-ref --tags
git push origin
git push --force origin "$version"
7 changes: 5 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

# -- Project setup --------------------------------------------------------------

import tomllib

import zenoh

# -- Project information -----------------------------------------------------
Expand All @@ -31,8 +33,9 @@
copyright = '2020, ZettaScale Zenoh team, <zenoh@zettascale.tech>'
author = 'ZettaScale Zenoh team, <zenoh@zettascale.tech>'

# The full version, including alpha/beta/rc tags
release = '0.11.0-dev'
# Extract the release number from the Cargo manifest
with open("../Cargo.toml", "rb") as f:
release = tomllib.load(f)["package"]["version"]


# -- General configuration ---------------------------------------------------
Expand Down