Skip to content

Commit

Permalink
add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanbuel committed Jan 3, 2023
1 parent b451a6f commit 3948ee0
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/fig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Push fig spec

on:
workflow_dispatch:

jobs:
push-to-fig-autocomplete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Place fig spec in correct folder
shell: bash
run: |
cp target/release/build/**/out/pattrick.ts pattrick.ts
- name: Create Autocomplete PR ## Create the autocomplete PR using this action
uses: withfig/push-to-fig-autocomplete-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
autocomplete-spec-name: pattrick
spec-path: pattrick.ts
integration: clap
102 changes: 102 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build release binaries

on:
workflow_dispatch:
push:
tags:
- "*"

env:
CARGO_TERM_COLOR: always

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
target:
[
aarch64-unknown-linux-gnu,
i686-unknown-linux-gnu,
i686-unknown-linux-musl,
x86_64-unknown-linux-gnu,
x86_64-unknown-linux-musl,
]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../pattrick-${{ matrix.target }}.tar.gz pattrick
cd -
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 1.0.0
- name: Publish
uses: softprops/action-gh-release@v1
# TODO: if any of the build step fails, the release should be deleted.
with:
files: 'pattrick*'
tag_name: ${{ steps.previoustag.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-mac:
runs-on: macos-latest
strategy:
matrix:
target: [aarch64-apple-darwin, x86_64-apple-darwin]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../pattrick-${{ matrix.target }}.tar.gz pattrick
cd -
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 1.0.0
- name: Publish
uses: softprops/action-gh-release@v1
# TODO: if any of the build step fails, the release should be deleted.
with:
files: 'pattrick*'
tag_name: ${{ steps.previoustag.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Rust
name: Build and test project

on:
push:
branches: [ "main" ]
paths:
- "**.rs"
- "Cargo.toml"
- "Cargo.lock"
pull_request:
branches: [ "main" ]

Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
![docs](https://img.shields.io/docsrs/pattrick)
![license](https://img.shields.io/crates/l/pattrick)


Pattrick is a command line tool for managing Personal Access Tokens (PAT) in Azure DevOps.

It allows you to:
Expand All @@ -29,7 +28,7 @@ brew install pattrick
On Linux, you can install Pattrick by executing the following commands:

```bash
curl -L https://github.com/jvanbuel/pattrick/releases/download/v0.3.0/pattrick-x86_64-unknown-linux-gnu.tar.gz | tar xvz
curl -L https://github.com/jvanbuel/pattrick/releases/latest/download/pattrick-x86_64-unknown-linux-gnu.tar.gz | tar xvz
chmod +x pattrick
sudo mv pattrick /usr/local/bin/pattrick
```
Expand All @@ -41,16 +40,21 @@ Pattrick looks for Azure CLI credentials to fetch an access token for authentica
```bash
az login
```
If `pattrick` cannot find a valid access token, it will try to log you in automatically (by using the `az login` command under the hood). You can then start using `pattrick` to manage your PAT tokens:

If `pattrick` cannot find a valid access token, it will try to log you in automatically (by using the `az login` command under the hood). You can then start using `pattrick` to manage your PAT tokens:

```bash
pattrick create --lifetime 100 --scope Packaging
```
By default, `pattrick` writes newly created token to stdout. However, you can also tell `pattrick` to write the token to your `.netrc` file (useful for e.g. install Python packages from Azure DevOps Artifacts), or to a local `.env` file:

By default, `pattrick` writes newly created token to stdout. However, you can also tell `pattrick` to write the token to your `.netrc` file (useful for e.g. installing Python packages from Azure DevOps Artifacts), or to a local `.env` file:

```bash
pattrick create --out std-out (default) / dot-netrc / dot-env
```
To get an overview of the other commands an options available, run:

To get an overview of the other commands and options available, run:

```bash
pattrick --help
```
Expand All @@ -71,4 +75,5 @@ let pat_tokens = pat_manager.list_pat_tokens(
}
).await?;
```

For more information, check out the `pattrick` documentation at [docs.rs](https://docs.rs/pattrick/latest/pattrick/)

0 comments on commit 3948ee0

Please sign in to comment.