Skip to content

Commit 10c7b1d

Browse files
authored
Release github actions workflow. (#8)
* package: Add cargo-binstall metadata.
1 parent b794add commit 10c7b1d

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
name: Building for ${{ matrix.config.os }}
15+
runs-on: ${{ matrix.config.os }}
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
config:
21+
- os: ubuntu-latest
22+
rust_target: x86_64-unknown-linux-gnu
23+
ext: ""
24+
- os: macos-latest
25+
rust_target: x86_64-apple-darwin
26+
ext: ""
27+
- os: macos-latest
28+
rust_target: aarch64-apple-darwin
29+
ext: ""
30+
- os: windows-latest
31+
rust_target: x86_64-pc-windows-msvc
32+
ext: ".exe"
33+
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: "Setup Rust"
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
targets: ${{ matrix.config.rust_target }}
40+
- uses: Swatinem/rust-cache@v2
41+
with:
42+
key: ${{ matrix.config.rust_target }}
43+
- name: Cargo Build
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: build
47+
args: --release --target ${{ matrix.config.rust_target }}
48+
- name: Create Assets
49+
shell: bash
50+
run: |
51+
BINARY_FILENAME="target/${{ matrix.config.rust_target }}/release/tyedev${{ matrix.config.ext }}"
52+
VERSION="${GITHUB_REF#refs/tags/v}"
53+
RELEASE_NAME=tyedev-${VERSION}-${{ matrix.config.rust_target }}
54+
mkdir "${RELEASE_NAME}"
55+
cp LICENSE.txt README.md "${BINARY_FILENAME}" "${RELEASE_NAME}"
56+
tar -cvzf "${RELEASE_NAME}.tar.gz" "${RELEASE_NAME}"
57+
if [[ ${{ runner.os }} == 'Windows' ]]; then
58+
certutil -hashfile "${RELEASE_NAME}.tar.gz" sha256 | grep -E '[A-Fa-f0-9]{64}' > "${RELEASE_NAME}.sha256"
59+
else
60+
shasum -a 256 "${RELEASE_NAME}.tar.gz" > "${RELEASE_NAME}.sha256"
61+
fi
62+
- name: Release Assets
63+
uses: softprops/action-gh-release@v1
64+
with:
65+
files: |
66+
tyedev-*.tar.gz
67+
tyedev-*.sha256
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
publish-crate:
72+
name: Publishing to crates.io
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v3
76+
- name: Install Rust Toolchain
77+
uses: dtolnay/rust-toolchain@stable
78+
- uses: Swatinem/rust-cache@v2
79+
- run: cargo publish
80+
env:
81+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ keywords = ["devcontainers", "containers", "vscode", "development", "configurati
1111
categories = ["config", "command-line-utilities", "development-tools", "virtualization"]
1212
include = ["LICENSE.txt", "src/", "static/"]
1313

14+
[package.metadata.binstall]
15+
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ version }-{ target }{ archive-suffix }"
16+
bin-dir = "{ name }-{ version }-{ target }/{ bin }{ binary-ext }"
17+
pkg-fmt = "tgz"
18+
1419
[dependencies]
1520
ascii_table = { version = "4.0.3", features = ["auto_table_width"] }
1621
clap = { version = "4.4.6", features = ["derive", "wrap_help"] }

0 commit comments

Comments
 (0)