Skip to content

Commit

Permalink
ci: add covector & publishing workflows (#36)
Browse files Browse the repository at this point in the history
* ci: add covector & publishing workflows

* dependencies

* use commit hash

* inherit worksapce authors

* Update .github/workflows/covector-version-or-publish.yml
  • Loading branch information
amr-crabnebula committed Oct 4, 2023
1 parent a99bbac commit 576782b
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .changes/config.json
Original file line number Diff line number Diff line change
@@ -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 '<details>\n<summary><em><h4>Cargo Publish</h4></em></summary>\n\n```'",
"dryRunCommand": true,
"pipe": true
},
{
"command": "cargo publish",
"dryRunCommand": "cargo publish --dry-run",
"pipe": true
},
{
"command": "echo '```\n\n</details>\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"
}
]
}
}
}
29 changes: 29 additions & 0 deletions .changes/readme.md
Original file line number Diff line number Diff line change
@@ -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).
16 changes: 16 additions & 0 deletions .github/workflows/covector-status.yml
Original file line number Diff line number Diff line change
@@ -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"
46 changes: 46 additions & 0 deletions .github/workflows/covector-version-or-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
members = ["crates/*", "examples/*"]
exclude = ["examples/deno"]
resolver = "2"

[workspace.package]
authors = ["CrabNebula Ltd."]

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/packager/src/cli/signer/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion crates/updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 576782b

Please sign in to comment.