-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from sean0x42/v2
Release markdown extract v2
- Loading branch information
Showing
21 changed files
with
370 additions
and
355 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,2 @@ | ||
/target/ | ||
/.git/ |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z $RELEASE_NAME ]]; then | ||
echo "Missing env var RELEASE_NAME" | ||
exit 1 | ||
fi | ||
|
||
pattern="^$RELEASE_NAME" | ||
|
||
notes=$(docker run -v $PWD:/opt -it sean0x42/markdown-extract:v2 \ | ||
--no-print-matched-heading \ | ||
$pattern \ | ||
/opt/CHANGELOG.md) | ||
|
||
notes=="${notes=//'%'/'%25'}" | ||
notes=="${notes=//$'\n'/'%0A'}" | ||
notes=="${notes=//$'\r'/'%0D'}" | ||
|
||
echo "::set-output name=value::$notes" |
6 changes: 3 additions & 3 deletions
6
.github/workflows/rust.yml → .github/workflows/build_and_test.yml
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,15 +1,15 @@ | ||
name: Rust | ||
name: Build & Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build | ||
run: cargo build --verbose | ||
|
||
- name: Run tests | ||
run: cargo test --verbose |
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,44 +1,36 @@ | ||
name: Create Release | ||
name: "Create Release" | ||
|
||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # e.g. v1.0, v20.15.10 | ||
# Matches anything starting with a semantic version | ||
- "v[0-9]+.[0-9]+.[0-9]+**" | ||
|
||
jobs: | ||
build: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
name: "Create Release" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install markdown-extract | ||
run: cargo install markdown-extract | ||
- name: "Checkout code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: Get tag string | ||
id: tag | ||
run: echo ::set-output name=value::${GITHUB_REF/refs\/tags\//} | ||
- name: "Construct tag string" | ||
id: "tag" | ||
run: "echo ::set-output name=value::${GITHUB_REF/refs\/tags\//}" | ||
|
||
- name: Get release body | ||
id: release_notes | ||
run: | | ||
text=`~/.cargo/bin/markdown-extract -i ${{ steps.tag.outputs.value }} CHANGELOG.md` | ||
echo $text | ||
text="${text//'%'/'%25'}" | ||
text="${text//$'\n'/'%0A'}" | ||
text="${text//$'\r'/'%0D'}" | ||
echo "::set-output name=value::$text" | ||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@master | ||
- name: "Extract release notes" | ||
id: "notes" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_NAME: ${{ steps.tags.outputs.value }} | ||
CHANGELOG_PATH: "./CHANGELOG.md" | ||
run: "./.github/scripts/extract_notes.sh" | ||
shell: "bash" | ||
|
||
- name: "Create release" | ||
uses: "softprops/action-gh-release@v1" | ||
with: | ||
name: "Release ${{ steps.tags.outputs.value }}" | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ steps.tags.outputs.value }} | ||
body: | | ||
${{ steps.release_notes.outputs.value }} | ||
body: ${{ steps.notes.outputs.value }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: 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
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,7 @@ | ||
[package] | ||
name = "markdown-extract" | ||
description = "Extract sections of a markdown file." | ||
version = "1.1.0" | ||
version = "2.0.0" | ||
authors = ["Sean Bailey <[email protected]>"] | ||
license = "MIT" | ||
repository = "https://github.com/sean0x42/markdown-extract" | ||
|
@@ -10,11 +10,13 @@ edition = "2018" | |
exclude = [".github/*"] | ||
readme = "README.md" | ||
|
||
[lib] | ||
path = "src/lib.rs" | ||
|
||
[[bin]] | ||
name = "markdown-extract" | ||
path = "src/bin.rs" | ||
|
||
[dependencies] | ||
log = "0.4" | ||
regex = "1.3" | ||
structopt = "0.3" |
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,8 +1,27 @@ | ||
FROM rust:1.43 as builder | ||
# Dockerfile for creating statically-linked Rust applications. | ||
# See: https://www.artificialworlds.net/blog/2020/04/22/creating-a-tiny-docker-image-of-a-rust-project/ | ||
# See: https://alexbrand.dev/post/how-to-package-rust-applications-into-minimal-docker-containers/ | ||
|
||
# 1: Build the exe | ||
FROM rust:1.57 as builder | ||
WORKDIR /usr/src | ||
|
||
# 1a: Prepare for static linking | ||
RUN apt-get update && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y musl-tools && \ | ||
rustup target add x86_64-unknown-linux-musl | ||
|
||
# 1b: Download and compile Rust dependencies (and store as a separate Docker layer) | ||
RUN USER=root cargo new markdown-extract | ||
WORKDIR /usr/src/markdown-extract | ||
COPY . . | ||
RUN cargo install --path . | ||
COPY Cargo.toml Cargo.lock ./ | ||
COPY src ./src | ||
RUN cargo install --target x86_64-unknown-linux-musl --path . | ||
|
||
FROM debian:buster-slim | ||
COPY --from=builder /usr/local/cargo/bin/markdown-extract /usr/local/bin/markdown-extract | ||
ENTRYPOINT ["markdown-extract"] | ||
# 2: Copy the exe and extra files ("static") to an empty Docker image | ||
FROM scratch | ||
COPY --from=builder /usr/local/cargo/bin/markdown-extract . | ||
# COPY static . | ||
USER 1000 | ||
ENTRYPOINT ["./markdown-extract"] |
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
Oops, something went wrong.