-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import re | ||
import pathlib | ||
import sys | ||
|
||
|
||
_STDIO = pathlib.Path("-") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-i", "--input", type=pathlib.Path, default="CHANGELOG.md") | ||
parser.add_argument("--tag", required=True) | ||
parser.add_argument("-o", "--output", type=pathlib.Path, required=True) | ||
args = parser.parse_args() | ||
|
||
if args.input == _STDIO: | ||
lines = sys.stdin.readlines() | ||
else: | ||
with args.input.open() as fh: | ||
lines = fh.readlines() | ||
version = args.tag.lstrip("v") | ||
|
||
note_lines = [] | ||
for line in lines: | ||
if line.startswith("## ") and version in line: | ||
note_lines.append(line) | ||
elif note_lines and line.startswith("## "): | ||
break | ||
elif note_lines: | ||
note_lines.append(line) | ||
|
||
notes = "".join(note_lines).strip() | ||
if args.output == _STDIO: | ||
print(notes) | ||
else: | ||
args.output.write_text(notes) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: release | ||
permissions: | ||
contents: write | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
env: | ||
BIN_NAME: kubectl-resource_status | ||
jobs: | ||
create-release: | ||
name: create-release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
upload_url: ${{ steps.release.outputs.upload_url }} | ||
release_version: ${{ github.ref_name }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Generate Release Notes | ||
run: | | ||
./.github/workflows/release-notes.py --tag ${{ github.ref_name }} --output notes-${{ github.ref_name }}.md | ||
cat notes-${{ github.ref_name }}.md | ||
- name: Create GitHub release | ||
id: release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: notes-${{ github.ref_name }}.md | ||
build-release: | ||
name: build-release | ||
needs: create-release | ||
strategy: | ||
matrix: | ||
build: [x86_64-apple-darwin, aarch64-apple-darwin] | ||
include: | ||
- build: x86_64-apple-darwin | ||
os: macos-latest | ||
rust: stable | ||
target: x86_64-apple-darwin | ||
- build: aarch64-apple-darwin | ||
os: macos-latest | ||
rust: stable | ||
target: aarch64-apple-darwin | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
- name: Build release binary | ||
run: cargo build --target ${{ matrix.target }} --release | ||
- name: Build archive | ||
shell: bash | ||
run: | | ||
bin_dir="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.release_version }}-${{ matrix.target }}" | ||
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$bin_dir/" | ||
tar czf "$bin_dir.tar.gz" -C "$bin_dir" . | ||
echo "ASSET=$bin_dir.tar.gz" >> $GITHUB_ENV | ||
- name: Upload release archive | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ env.ASSET }} | ||
homebrew-releaser: | ||
runs-on: ubuntu-latest | ||
needs: build-release | ||
name: homebrew-releaser | ||
steps: | ||
- name: Release to Homebrew tap | ||
uses: Justintime50/homebrew-releaser@v1 | ||
with: | ||
homebrew_owner: nothinux | ||
homebrew_tap: homebrew-tools | ||
formula_folder: formula | ||
github_token: ${{ secrets.TAP_TOKEN }} | ||
install: 'bin.install "kubectl-resource_status"' | ||
target_darwin_amd64: true | ||
target_darwin_arm64: true | ||
target_linux_amd64: true | ||
target_linux_arm64: false | ||
update_readme_table: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
name: Test | ||
on: | ||
push: | ||
paths: | ||
- "src/**.rs" | ||
pull_request: | ||
paths: | ||
- "src/**.rs" | ||
|
||
jobs: | ||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|