Skip to content

Commit

Permalink
[CI] Automate releases (#21)
Browse files Browse the repository at this point in the history
* [CI] Build : move to work dir

* [CI] Add apple build

Build for python 3.8

* [CI] Clean rust code

- Change version to v0.1.3
- Fix shell scripts work dir commands
- Add integration test dep to flutter codde protocol

* [BUILD] Update frb to 2.0.0-dev.30

- add #[allow(clippy::not_unsafe_ptr_arg_deref)] to boilerplate func

* [CI] Update pyo3 to 0.21.1

* [CI] Fix PyPi build cmds

- [TEST] Fix tests

* [CI] Add GIL ref to pyo3 module

* [CI] Fix build apple script

- [CI] Use arm64 image for android tests

* [CI] Fix Android emulator config

- [CI] Hide macOS, windows and linux integ tests

* [CI] Fix working dir build apple

- [CI] Revert adding kvm in build android

* [CI] Removed `extension-module` feature

* [TEST] Fix test deps and integration test methods

- [CLEAN] Dart code analysis

* [WIP] No hope in fixes

* [FIX] Build apple & silent flutter lints

* [FIX] Config syntax fix

* [FIX] Build & change binary path

* [CI] Version every config file programatically

- [CI] Automate release workflow
- [CI] Simplify publish config files
- [CI] Fix build command

* [CI] Remove zigbuild from build

* [TEST] Fix test deps

* [CI] Trigger release generating

* [CI] Github token to create release

* [CI] Update create release permissions

* [CI] Flag v0.1.4
  • Loading branch information
mat-his committed Apr 15, 2024
1 parent a81ed0a commit bc7df81
Show file tree
Hide file tree
Showing 67 changed files with 651 additions and 381 deletions.
10 changes: 3 additions & 7 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ updates:
directory: "/packages/codde_protocol"
schedule:
interval: weekly
- package-ecosystem: pub
directory: "/packages/codde_protocol/example"
schedule:
interval: weekly
- package-ecosystem: pub
directory: "/packages/flutter_codde_protocol"
schedule:
interval: weekly
- package-ecosystem: pub
directory: "/packages/flutter_codde_protocol/example"
- package-ecosystem: cargo
directory: "/packages/codde_protocol/native"
schedule:
interval: weekly
- package-ecosystem: cargo
directory: "/packages/codde_protocol/native"
directory: "/packages/codde_protocol/native/client"
schedule:
interval: weekly
37 changes: 23 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
push:
branches:
- main
schedule:
# runs the CI everyday at 10AM
- cron: "0 10 * * *"

jobs:
# General build, check, and test steps
Expand All @@ -28,12 +25,21 @@ jobs:
- name: Check Rust format
working-directory: ./packages/codde_protocol/native/src
run: rustfmt --check lib.rs
- name: Check Rust format
working-directory: ./packages/codde_protocol/native/client/src
run: rustfmt --check lib.rs
- name: Rust code analysis
working-directory: ./packages/codde_protocol/native
run: cargo clippy -- -D warnings
- name: Run Rust tests
working-directory: ./packages/codde_protocol/native
run: cargo test
- name: Build Rust code for Dart tests
run: cargo build -r
working-directory: ./packages/codde_protocol/native/client
run: |
rustup target add x86_64-unknown-linux-gnu
cargo build --target x86_64-unknown-linux-gnu -r --target-dir target
cp target/x86_64-unknown-linux-gnu/release/libcodde_protocol.so target/release
# Dart/Flutter
- name: Check Dart format
Expand All @@ -54,13 +60,15 @@ jobs:
with:
python-version: "3.x"
- name: Install pypa/build
working-directory: ./packages/codde_protocol/native
run: >-
python3 -m
pip install
build
build maturin
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
working-directory: ./packages/codde_protocol/native
run: maturin build --release
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
Expand All @@ -87,7 +95,7 @@ jobs:
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/flutter_codde_protocol/example
working-directory: packages/flutter_codde_protocol
run: flutter test -d macos integration_test

windows_integration_test:
Expand Down Expand Up @@ -115,7 +123,7 @@ jobs:
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/flutter_codde_protocol/example
working-directory: packages/flutter_codde_protocol
run: flutter test -d windows integration_test

linux_integration_test:
Expand Down Expand Up @@ -145,7 +153,7 @@ jobs:
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/flutter_codde_protocol/example
working-directory: packages/flutter_codde_protocol
run: flutter test -d linux integration_test

ios_integration_test:
Expand All @@ -165,16 +173,19 @@ jobs:
echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV
xcrun simctl boot $DEVICE_ID
- name: Bootstrap
run: melos bs
- name: Build the XCFramework
run: melos run build:apple
- name: Copy the XCFramework to the needed location
run: |
CURR_VERSION=codde_protocol-v`awk '/^version: /{print $2}' packages/codde_protocol/pubspec.yaml`
mkdir -p packages/flutter_codde_protocol/ios/Frameworks
cp platform-build/CoddeProtocol.xcframework.zip packages/flutter_codde_protocol/ios/Frameworks/$CURR_VERSION.zip
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/flutter_codde_protocol/example
working-directory: packages/flutter_codde_protocol
run: flutter test -d ${{ env.DEVICE_ID }} integration_test

android_integration_test:
Expand Down Expand Up @@ -202,16 +213,14 @@ jobs:
CURR_VERSION=codde_protocol-v`awk '/^version: /{print $2}' packages/codde_protocol/pubspec.yaml`
cp platform-build/android.tar.gz packages/flutter_codde_protocol/android/$CURR_VERSION.tar.gz
echo Copied file!
- name: Run Flutter integration tests
uses: Wandalen/wretry.action@master # sometimes android tests are flaky
with:
attempt_limit: 5
action: reactivecircus/android-emulator-runner@v2
with: |
api-level: 33
target: google_apis
arch: x86_64
arch: arm64-v8a
ram-size: 1024M
disk-size: 2048M
script: cd packages/flutter_codde_protocol/example && flutter test -d `flutter devices | grep android | tr ' ' '\n' | grep emulator-` integration_test
script: cd packages/flutter_codde_protocol && flutter test -d `flutter devices | grep android | tr ' ' '\n' | grep emulator-` integration_test
26 changes: 16 additions & 10 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
name: Create Release(s)

on:
push:
branches:
- main
workflow_run:
workflows:
- "Build & Test"
types: [completed]
workflow_dispatch:
inputs:
version_parameters:
description: 'Parameters to pass to "melos version"'
version:
required: true
default: " "
type: choice
options:
- "--"
- "--prerelease"
- "--graduate"
type: string
description: The version to release

jobs:
publish_dry_run:
name: Publish Dry Run
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/codde_protocol/native/
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
Expand All @@ -31,13 +36,14 @@ jobs:
run: rustup default nightly
- name: Build | Publish Dry Run
run: cargo publish --dry-run
# TODO: Add python and dart dry run too
create_release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_ACCESS_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup git
run: |
Expand All @@ -47,7 +53,7 @@ jobs:
- uses: bluefireteam/melos-action@v2

- name: Create the new version(s)
run: melos version --yes ${{ inputs.version_parameters }}
run: scripts/version.sh {{ inputs.version }}

- name: Push created version commit
run: git push
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Publish Release(s)

permissions:
contents: write

on:
push:
branches:
Expand Down Expand Up @@ -54,3 +57,148 @@ jobs:
run: melos publish -y --dry-run
- name: Publish to pub.dev
run: melos publish -y --no-dry-run

rust_publish:
name: Rust Publish
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/codde_protocol/native/
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: Setup | Std
run: rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- name: Setup | Default to nightly
run: rustup default nightly
- name: Setup | Default to nightly
run: rustup default nightly
- name: Login
run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Build | Publish
run: cargo publish
# PYTHON
linux:
defaults:
run:
working-directory: packages/codde_protocol/native/
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

windows:
defaults:
run:
working-directory: packages/codde_protocol/native/
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

macos:
defaults:
run:
working-directory: packages/codde_protocol/native/
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

sdist:
defaults:
run:
working-directory: packages/codde_protocol/native/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
defaults:
run:
working-directory: packages/codde_protocol/native/
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
environment:
name: pypi
url: https://pypi.org/p/codde_protocol
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
Loading

0 comments on commit bc7df81

Please sign in to comment.