Skip to content

Commit

Permalink
feat: Automate Release (#71)
Browse files Browse the repository at this point in the history
* feat: Store project version in version.txt

* fix: Remove cargo-deb metadata section in `zenoh-jni`

* feat: Add `bump-and-tag.bash` script

* chore: Rename release workflow to pre-release

* chore: Disable release event on publish workflows

* fix: Typo in ci/scripts

* feat: Automate Release

* chore: Remove enforce-linking-issues workflow

* fix: Set permissions for publishing jobs

* feat: Add publish-dokka to release workflow

* fix: Set release branch in publishing jobs

* fix: Make `branch` input unrequired in publishing jobs

* style: Uniformize publishing workflow names

* fix: Unecessary use of `BOT_TOKEN_WORKFLOW`

* fix: Incorrect Cargo manifest/lockfile path

* fix: Add missing `live-run` input for publish-dokka job

* fix: Typo in pre-release workflow name

* fix: Remove `if: always()` in publish-github job

* fix: Remove unecessary SSH passphrase/privatekey inputs

* chore: Retrigger CI

* fix: Support jq 1.6

ubuntu-22.04 runners use jq 1.6 which doesn't recognize a dot for `[]` value iterator.

See: jqlang/jq#1168.
  • Loading branch information
fuzzypixelz authored Apr 17, 2024
1 parent 59ce031 commit 1238f92
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
name: Publish JVM snapshot package
if: github.ref == 'refs/heads/main'
needs: ci
uses: ./.github/workflows/publish_jvm.yml
uses: ./.github/workflows/publish-jvm.yml
permissions:
contents: read
packages: write
Expand All @@ -96,7 +96,7 @@ jobs:
name: Publish Android snapshot package
if: github.ref == 'refs/heads/main'
needs: ci
uses: ./.github/workflows/publish_android.yml
uses: ./.github/workflows/publish-android.yml
permissions:
contents: read
packages: write
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/enforce-linking-issues.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Pre-Release

on:
schedule:
- cron: "0 1 * * 1-5"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
release:
name: Build on ${{ matrix.os }}
runs-on: ["${{ matrix.os }}"]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26
add-to-path: false
link-to-sdk: true

- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy
- name: Cargo Format
working-directory: zenoh-jni
run: cargo fmt --all --check

- name: Clippy Check
working-directory: zenoh-jni
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Check for feature leaks
working-directory: zenoh-jni
run: cargo test --no-default-features

- name: Build Zenoh-JNI
working-directory: zenoh-jni
run: cargo build

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Gradle Test
run: gradle jvmTest --info
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Publish Android
name: Publish (Android)

on:
release:
types: [published]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
description: "If the publication is for a snapshot version."
default: false
branch:
description: Target branch
type: string
required: false
workflow_dispatch:

env:
Expand All @@ -24,6 +26,8 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- uses: actions/setup-java@v3
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
name: Publish Documentation
name: Publish (Dokka)

on:
release:
types: [published]
workflow_call:
inputs:
live-run:
description: Live-run
type: boolean
required: true
branch:
description: Target branch
type: string
required: false
workflow_dispatch:

env:
Expand All @@ -14,6 +22,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- uses: nttld/setup-ndk@v1
id: setup-ndk
Expand All @@ -26,6 +36,7 @@ jobs:
run: gradle dokkaHtml

- name: Deploy doc
if: ${{ inputs.live-run || false }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
name: Publish JVM
name: Publish (JVM)

on:
release:
types: [published]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
description: "If the publication is for a snapshot version."
default: false
branch:
description: Target branch
type: string
required: false
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
JNI_LIB_PATHS: jni-libs # Edit on the inner build.gradle.kts file as well.
JNI_LIB_PATHS: jni-libs # Edit on the inner build.gradle.kts file as well.

jobs:
builds:
Expand Down Expand Up @@ -59,14 +61,16 @@ jobs:
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo install cargo-deb ;;
esac
case ${{ matrix.job.target }} in
aarch64-unknown-linux-gnu)
sudo apt-get -y update
Expand All @@ -90,7 +94,7 @@ jobs:
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/${TARGET}.zip"
case ${TARGET} in
*linux*)
cd "zenoh-jni/target/${TARGET}/release/"
Expand Down Expand Up @@ -132,6 +136,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Create resources destination
run: mkdir ${{env.JNI_LIB_PATHS}}
Expand Down
132 changes: 86 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,102 @@
#
# Copyright (c) 2022 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# ZettaScale Zenoh Team, <[email protected]>
#
name: Release

on:
release:
types: [published]
schedule:
- cron: "0 1 * * 1-5"
- cron: "0 0 * * 1-5"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
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:
release:
name: Build on ${{ matrix.os }}
runs-on: [ "${{ matrix.os }}" ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest ]

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:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
- id: create-release-branch
uses: eclipse-zenoh/ci/create-release-branch@main
with:
distribution: temurin
java-version: 11
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ inputs.version }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- uses: nttld/setup-ndk@v1
id: setup-ndk
- name: Checkout this repository
uses: actions/checkout@v4
with:
ndk-version: r26
add-to-path: false
link-to-sdk: true

- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy
ref: ${{ steps.create-release-branch.outputs.branch }}

- name: Cargo Format
working-directory: zenoh-jni
run: cargo fmt --all --check
- 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: [email protected]

- name: Clippy Check
working-directory: zenoh-jni
run: cargo clippy --all-targets --all-features -- -D warnings
publish-jvm:
name: Publish JVM package
needs: tag
uses: ./.github/workflows/publish-jvm.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
permissions:
contents: read
packages: write

- name: Check for feature leaks
working-directory: zenoh-jni
run: cargo test --no-default-features
publish-android:
name: Publish Android package
needs: tag
uses: ./.github/workflows/publish-android.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
permissions:
contents: read
packages: write

- name: Build Zenoh-JNI
working-directory: zenoh-jni
run: cargo build
publish-dokka:
name: Publish documentation
needs: tag
uses: ./.github/workflows/publish-dokka.yml
with:
live-run: ${{ inputs.live-run || false }}

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Gradle Test
run: gradle jvmTest --info
publish-github:
needs: tag
runs-on: macos-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 }}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//

val zenohGroup = "io.zenoh"
val zenohVersion = "1.0.0"
val zenohVersion = file("version.txt").readText()

buildscript {
repositories {
Expand Down
Loading

0 comments on commit 1238f92

Please sign in to comment.