From 576782b5bbc152bf919d9ad0056eeea2b7a33871 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 5 Oct 2023 00:57:41 +0300 Subject: [PATCH] ci: add covector & publishing workflows (#36) * ci: add covector & publishing workflows * dependencies * use commit hash * inherit worksapce authors * Update .github/workflows/covector-version-or-publish.yml --- .changes/config.json | 59 +++++++++++++++++++ .changes/readme.md | 29 +++++++++ .github/workflows/covector-status.yml | 16 +++++ .../workflows/covector-version-or-publish.yml | 46 +++++++++++++++ Cargo.toml | 2 + crates/packager/src/cli/signer/sign.rs | 2 +- crates/updater/Cargo.toml | 2 +- 7 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 .changes/config.json create mode 100644 .changes/readme.md create mode 100644 .github/workflows/covector-status.yml create mode 100644 .github/workflows/covector-version-or-publish.yml diff --git a/.changes/config.json b/.changes/config.json new file mode 100644 index 00000000..1eb3eb58 --- /dev/null +++ b/.changes/config.json @@ -0,0 +1,59 @@ +{ + "gitSiteUrl": "https://www.github.com/crabnebula-dev/cargo-packager", + "timeout": 3600000, + "pkgManagers": { + "rust": { + "version": true, + "getPublishedVersion": "cargo search ${ pkg.pkg } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p' -", + "publish": [ + { + "command": "cargo package --no-verify", + "dryRunCommand": true + }, + { + "command": "echo '
\n

Cargo Publish

\n\n```'", + "dryRunCommand": true, + "pipe": true + }, + { + "command": "cargo publish", + "dryRunCommand": "cargo publish --dry-run", + "pipe": true + }, + { + "command": "echo '```\n\n
\n'", + "dryRunCommand": true, + "pipe": true + } + ], + "postpublish": [ + "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor } -f", + "git tag ${ pkg.pkg }-v${ pkgFile.versionMajor }.${ pkgFile.versionMinor } -f", + "git push --tags -f" + ] + } + }, + "packages": { + "cargo-packager-config": { + "path": "./crates/config", + "manager": "rust", + "assets": [ + { + "path": "${ pkg.path }/target/package/cargo-packager-config-${ pkgFile.version }.crate", + "name": "${ pkg.pkg }-${ pkgFile.version }.crate" + } + ] + }, + "cargo-packager": { + "path": "./crates/packager", + "manager": "rust", + "dependencies": ["cargo-packager-config"], + "assets": [ + { + "path": "${ pkg.path }/target/package/cargo-packager-${ pkgFile.version }.crate", + "name": "${ pkg.pkg }-${ pkgFile.version }.crate" + } + ] + } + } +} diff --git a/.changes/readme.md b/.changes/readme.md new file mode 100644 index 00000000..40426c60 --- /dev/null +++ b/.changes/readme.md @@ -0,0 +1,29 @@ +# Changes + +##### via https://github.com/jbolda/covector + +As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version _number_, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend it represents the overall change for our sanity. + +When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process. + +Use the following format: + +```md +--- +"cargo-packager": patch +--- + +Change summary goes here +``` + +Summaries do not have a specific character limit, but are text only. These summaries are used within the (future implementation of) changelogs. They will give context to the change and also point back to the original PR if more details and context are needed. + +Changes will be designated as a `major`, `minor` or `patch` as further described in [semver](https://semver.org/). + +Given a version number MAJOR.MINOR.PATCH, increment the: + +- MAJOR version when you make incompatible API changes, +- MINOR version when you add functionality in a backwards compatible manner, and +- PATCH version when you make backwards compatible bug fixes. + +Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, but will be discussed prior to usage (as extra steps will be necessary in consideration of merging and publishing). diff --git a/.github/workflows/covector-status.yml b/.github/workflows/covector-status.yml new file mode 100644 index 00000000..de14a076 --- /dev/null +++ b/.github/workflows/covector-status.yml @@ -0,0 +1,16 @@ +name: covector status +on: [pull_request] + +jobs: + covector: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: covector status + uses: jbolda/covector/packages/action@covector-v0 + id: covector + with: + command: "status" diff --git a/.github/workflows/covector-version-or-publish.yml b/.github/workflows/covector-version-or-publish.yml new file mode 100644 index 00000000..342d2abe --- /dev/null +++ b/.github/workflows/covector-version-or-publish.yml @@ -0,0 +1,46 @@ +name: covector version or publish + +on: + push: + branches: + - main + +jobs: + version-or-publish: + runs-on: ubuntu-latest + timeout-minutes: 65 + outputs: + change: ${{ steps.covector.outputs.change }} + commandRan: ${{ steps.covector.outputs.commandRan }} + successfulPublish: ${{ steps.covector.outputs.successfulPublish }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: cargo login + run: cargo login ${{ secrets.CRATES_IO_TOKEN }} + - name: git config + run: | + git config --global user.name "${{ github.event.pusher.name }}" + git config --global user.email "${{ github.event.pusher.email }}" + + - name: covector version or publish (publish when no change files present) + uses: jbolda/covector/packages/action@covector-v0 + id: covector + with: + token: ${{ secrets.GITHUB_TOKEN }} + command: 'version-or-publish' + createRelease: true + + - name: Create Pull Request With Versions Bumped + if: steps.covector.outputs.commandRan == 'version' + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: release/version-updates + title: 'release: apply version updates from current changes' + commit-message: 'release: apply version updates from current changes' + labels: 'version updates' + body: ${{ steps.covector.outputs.change }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index e000f548..6345f10c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ members = ["crates/*", "examples/*"] exclude = ["examples/deno"] resolver = "2" + +[workspace.package] authors = ["CrabNebula Ltd."] [workspace.dependencies] diff --git a/crates/packager/src/cli/signer/sign.rs b/crates/packager/src/cli/signer/sign.rs index 55c9ec53..070549c8 100644 --- a/crates/packager/src/cli/signer/sign.rs +++ b/crates/packager/src/cli/signer/sign.rs @@ -8,7 +8,7 @@ use std::path::PathBuf; use clap::Parser; #[derive(Debug, Clone, Parser)] -#[clap(about = "Sign a file.")] +#[clap(about = "Sign a file")] pub struct Options { /// Load the private key from a file or a string. #[clap(short = 'k', long, env = "CARGO_PACKAGER_SIGN_PRIVATE_KEY")] diff --git a/crates/updater/Cargo.toml b/crates/updater/Cargo.toml index 897817f2..ddbddbd5 100644 --- a/crates/updater/Cargo.toml +++ b/crates/updater/Cargo.toml @@ -2,7 +2,7 @@ name = "cargo-packager-updater" version = "0.0.0" description = "Rust executable updater." -authors = ["CrabNebula Ltd."] +authors.workspace = true edition = "2021" license = "Apache-2.0 OR MIT" repository = "https://github.com/crabnebula-dev/cargo-packager"