Skip to content

Commit

Permalink
fix: build and info options
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaz committed Oct 4, 2020
1 parent 2d3d380 commit cdedf4e
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 85 deletions.
42 changes: 42 additions & 0 deletions .github/snippets/job-github-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
key: job-github-publish
value:
needs: versio-release
runs-on: ubuntu-latest
if: SNIPPET_not-skip-ci
outputs:
upload_url: ${{ steps.publish-to-github.outputs.upload_url }}
steps:
- name: Checkout release
uses: actions/checkout@v2
with:
ref: main
- name: Get versio
uses: chaaz/versio-actions/install@v1
- name: Find version
id: find-version
run: 'echo ::set-output name=version::$(versio -l none info -i 0 -F | jq -r ''.[0].full_version'')'
- name: Publish to GitHub
id: publish-to-github
uses: actions/create-release@v1
with:
tag_name: ${{ steps.find-version.outputs.version }}
release_name: (TODO) RELEASE FOR ${{ steps.find-version.outputs.version }}
body: |
(TODO) SUMMARY
- (TODO) FEATURE1
New to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.
To install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):
```sh
curl -L https://github.com/chaaz/versio/releases/download/${{ steps.find-version.outputs.version }}/versio__x86_64-apple-darwin -o ~/bin/versio
chmod +x ~/bin/versio
```
**MacOS:** download `versio__x86_64-apple-darwin`, copy to `versio` in your PATH.
**GNU Linux 64:** download `versio__x86_64-unknown-linux-gnu`, copy to `versio` in your PATH.
**Windows:** download `versio__x86_64-pc-win32`, copy to `versio` in your %PATH.
draft: true
prerelease: false
commitish: main
38 changes: 38 additions & 0 deletions .github/snippets/job-publish-versio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
key: job-publish-versio
value:
needs: github-publish
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
root: '.'
rustflags: '-D warnings -C link-args=-s'
- os: macos-latest
target: x86_64-apple-darwin
root: '.'
rustflags: '-D warnings'
- os: windows-latest
target: x86_64-pc-win32
root: '.'
rustflags: '-D warnings'
if: SNIPPET_not-skip-ci
runs-on: ${{ matrix.os }}
steps:
- name: Checkout release
uses: actions/checkout@v2
with:
ref: main
- SNIPPET_get-cargo
- name: Build binary
run: cargo build --release
working-directory: ${{ matrix.root }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Upload binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.github-publish.outputs.upload_url }}
asset_path: ./target/release/versio
asset_name: versio__${{ matrix.target }}
asset_content_type: application/octet-stream
2 changes: 2 additions & 0 deletions .github/workflows-src/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ jobs:
cargo-checks: SNIPPET_job-cargo-checks
versio-release: SNIPPET_job-versio-release
cratesio-publish: SNIPPET_job-cratesio-publish
github-publish: SNIPPET_job-github-publish
publish-versio: SNIPPET_job-publish-versio
82 changes: 81 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,84 @@ jobs:
env:
CRATES_IO_TOKEN: "${{ secrets.CRATES_IO_TOKEN }}"
- name: Publish to crates.io
run: cargo publish
run: cargo publish
github-publish:
needs: versio-release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
outputs:
upload_url: "${{ steps.publish-to-github.outputs.upload_url }}"
steps:
- name: Checkout release
uses: actions/checkout@v2
with:
ref: main
- name: Get versio
uses: chaaz/versio-actions/install@v1
- name: Find version
id: find-version
run: "echo ::set-output name=version::$(versio -l none info -i 0 -F | jq -r '.[0].full_version')"
- name: Publish to GitHub
id: publish-to-github
uses: actions/create-release@v1
with:
tag_name: "${{ steps.find-version.outputs.version }}"
release_name: "(TODO) RELEASE FOR ${{ steps.find-version.outputs.version }}"
body: "(TODO) SUMMARY\n- (TODO) FEATURE1\n\nNew to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.\n\nTo install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):\n\n```sh\ncurl -L https://github.com/chaaz/versio/releases/download/${{ steps.find-version.outputs.version }}/versio__x86_64-apple-darwin -o ~/bin/versio\nchmod +x ~/bin/versio\n```\n\n**MacOS:** download `versio__x86_64-apple-darwin`, copy to `versio` in your PATH.\n**GNU Linux 64:** download `versio__x86_64-unknown-linux-gnu`, copy to `versio` in your PATH.\n**Windows:** download `versio__x86_64-pc-win32`, copy to `versio` in your %PATH.\n"
draft: true
prerelease: false
commitish: main
publish-versio:
needs: github-publish
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
root: "."
rustflags: "-D warnings -C link-args=-s"
- os: macos-latest
target: x86_64-apple-darwin
root: "."
rustflags: "-D warnings"
- os: windows-latest
target: x86_64-pc-win32
root: "."
rustflags: "-D warnings"
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: "${{ matrix.os }}"
steps:
- name: Checkout release
uses: actions/checkout@v2
with:
ref: main
- name: Get cargo stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Get cargo nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Find paths
id: cargo-find-paths
run: "echo ::set-output name=cargo-lock-glob::\"${{ matrix.root }}\"/**/Cargo.lock"
- name: Cache cargo and target
uses: actions/cache@v1
with:
path: "~/.cargo/registry\n~/.cargo/git\n${{ matrix.root }}/target\n"
key: "${{ runner.os }}-cargo-${{ hashFiles(steps.cargo-find-paths.outputs.cargo-lock-glob) }}"
- name: Build binary
run: cargo build --release
working-directory: "${{ matrix.root }}"
env:
RUSTFLAGS: "${{ matrix.rustflags }}"
- name: Upload binary
uses: actions/upload-release-asset@v1
with:
upload_url: "${{ needs.github-publish.outputs.upload_url }}"
asset_path: "./target/release/versio"
asset_name: "versio__${{ matrix.target }}"
asset_content_type: application/octet-stream
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/target
TODO*
/.versio-paused
/.versio-paused
/.versio-paused
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ up and running quickly with Versio. Or, try this and see what happens:

```
$ versio init # this creates .versio.yaml
$ git add .versio.yaml
$ git add .versio.yaml .gitignore
$ git commit -m "build: add versio management"
$ git push
$ versio release
Expand Down
33 changes: 33 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ along with their options and flags. You can always use `versio help` or
- `diff`: See differences between the current and previous versions.
- `files`: See all files that have changed since the previous version.
- `plan`: View the update plan.
- `info`: Outputs a JSON document with information about projects:
- `--id` (`-i <ID>`): include an ID'd project in the document (you can
provide this option more than once).
- `--name` (`-n <name>`): include a named project in the document (you
can provide this option more than once).
- `--label` (`-l <label>`): include all projects with a label (you can
provide this option more than once).
- `--all` (`-a`): include all projects.
- `--show-root` (`-R`): include the projects' root directories in the
document.
- `--show-name` (`-N`): include the projects' names in the document.

This command is useful to generate a machine-consumable document of
one or more of the project configurations. It's especially helpful to
create a matrix of projects that share a label. For example:
```
echo "::set-output name=matrix::{\"include\":$(versio -l none info -l cargo -R -N)}"
```
can be used to create a dynamic GitHub Actions matrix that contains
all "cargo" projects, which you can then use to run cargo-specific
jobs.
- `release`: Apply the update plan: update version numbers,
create/update changelogs, and commit/tag/push all changes.
- `--show-all` (`-a`): Show the run results for all projects, even
Expand Down Expand Up @@ -215,14 +236,18 @@ projects:
id: 1
root: "proj_1"
tag_prefix: "proj1"
labels: npm
version:
file: "package.json"
json: "version"
hooks:
post_write: ./bin/my_script.sh --auto

- name: proj_2
id: 2
root: "proj_2"
tag_prefix: ""
labels: go
version:
tags:
default: "0.0.0"
Expand Down Expand Up @@ -278,6 +303,14 @@ sizes:
- `subs`: If provided, allows a project to be subdivided into "major"
versions, each in its own subdirectory. See [Major
Subdirectories](./subs.md) for more info on this feature.
- `labels`: (optional) A string or sequence of strings, you can
arbitrary labels to you projects, which is useful when using the
`info` command.
- `hooks`: (optional) A set of hooks that run at certain points of the
release process. Currently, only the `post_write` hook is supported:
this hook runs after local file changes are made, but before any VCS
commits/push/tagging is performed; it's useful to make additional
file changes that need to be committed with the release.

- `sizes`

Expand Down
2 changes: 1 addition & 1 deletion docs/use_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ page](https://github.com/chaaz/versio/releases).
```
$ git pull
$ versio init # this creates .versio.yaml
$ git add .versio.yaml
$ git add .versio.yaml .gitignore
$ git commit -m "build: add versio management"
$ git push
```
Expand Down
58 changes: 51 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub fn execute(info: &EarlyInfo) -> Result<()> {
.long("show-all")
.takes_value(false)
.display_order(1)
.help("Also show unchnaged versions")
.help("Also show unchanged versions")
)
.arg(
Arg::with_name("pause")
Expand Down Expand Up @@ -285,7 +285,6 @@ pub fn execute(info: &EarlyInfo) -> Result<()> {
.arg(
Arg::with_name("all").short("a").long("all").takes_value(false).display_order(1).help("Info on all projects")
)
.group(ArgGroup::with_name("which").args(&["id", "name", "label", "all"]).required(false))
.arg(
Arg::with_name("showroot")
.short("R")
Expand All @@ -302,6 +301,38 @@ pub fn execute(info: &EarlyInfo) -> Result<()> {
.display_order(1)
.help("Show the project(s) name")
)
.arg(
Arg::with_name("showid")
.short("I")
.long("show-id")
.takes_value(false)
.display_order(1)
.help("Show the project(s) ID")
)
.arg(
Arg::with_name("showfull")
.short("F")
.long("show-full-version")
.takes_value(false)
.display_order(1)
.help("Show the project(s) full version with the tag prefix")
)
.arg(
Arg::with_name("showversion")
.short("V")
.long("show-version")
.takes_value(false)
.display_order(1)
.help("Show the project(s) version")
)
.arg(
Arg::with_name("showtagprefix")
.short("T")
.long("show-tag-prefix")
.takes_value(false)
.display_order(1)
.help("Show the project(s) tag prefix")
)
.display_order(1)
)
.get_matches();
Expand Down Expand Up @@ -339,11 +370,24 @@ fn parse_matches(m: ArgMatches) -> Result<()> {
("release", Some(m)) => release(pref_vcs, m.is_present("all"), m.is_present("dry"), m.is_present("pause"))?,
("init", Some(m)) => init(m.value_of("maxdepth").map(|d| d.parse().unwrap()).unwrap_or(5))?,
("info", Some(m)) => {
let names = m.values_of("name").map(|v| v.collect::<Vec<_>>());
let labels = m.values_of("label").map(|v| v.collect::<Vec<_>>());
let ids =
m.values_of("id").map(|v| v.map(|i| i.parse()).collect::<std::result::Result<Vec<_>, _>>()).transpose()?;
info(pref_vcs, ids, names, labels, m.is_present("all"), m.is_present("showname"), m.is_present("showroot"))?
let names = m.values_of("name").map(|v| v.collect::<Vec<_>>()).unwrap_or_default();
let labels = m.values_of("label").map(|v| v.collect::<Vec<_>>()).unwrap_or_default();
let ids = m
.values_of("id")
.map(|v| v.map(|i| i.parse()).collect::<std::result::Result<Vec<_>, _>>())
.transpose()?
.unwrap_or_default();

let show = InfoShow::new()
.pick_all(m.is_present("all"))
.show_name(m.is_present("showname"))
.show_root(m.is_present("showroot"))
.show_id(m.is_present("showid"))
.show_full_version(m.is_present("showfull"))
.show_version(m.is_present("showversion"))
.show_tag_prefix(m.is_present("showtagprefix"));

info(pref_vcs, ids, names, labels, show)?
}
("", _) => empty_cmd()?,
(c, _) => unknown_cmd(c)?
Expand Down
Loading

0 comments on commit cdedf4e

Please sign in to comment.