Skip to content

Commit 631c56e

Browse files
committed
v0.0.6 add lots of ci, add facicon
1 parent 81270ec commit 631c56e

11 files changed

Lines changed: 250 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: build
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
CARGO_TERM_COLOR: always
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
path:
11+
default: 'Cargo.toml'
12+
required: false
13+
type: string
14+
platform:
15+
default: 'ubuntu-latest'
16+
required: false
17+
type: string
18+
19+
jobs:
20+
ready:
21+
uses: ./.github/workflows/parse.yml
22+
with:
23+
path: ${{ inputs.path }}
24+
25+
cross-build:
26+
runs-on: ${{ inputs.platform }}
27+
needs:
28+
- ready
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: 'recursive'
33+
- uses: Swatinem/rust-cache@v2
34+
- uses: dtolnay/rust-toolchain@nightly
35+
- run: |
36+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
37+
cd wasm && RUSTFLAGS='--cfg getrandom_backend="wasm_js"' wasm-pack build --target web --release
38+
- name: Upload binaries to release
39+
uses: svenstaro/upload-release-action@v2
40+
with:
41+
repo_token: ${{ secrets.GITHUB_TOKEN }}
42+
file: wasm/pkg/*
43+
tag: ${{ github.ref }}
44+
overwrite: true
45+
file_glob: true

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ci
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
CARGO_TERM_COLOR: always
6+
CARGO: "Cargo.toml"
7+
8+
permissions:
9+
contents: write
10+
11+
on:
12+
workflow_dispatch:
13+
push:
14+
branches:
15+
- "master"
16+
paths:
17+
- ".github/workflows/ci.yml"
18+
- "Cargo.toml"
19+
20+
jobs:
21+
pre:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
path: ${{ env.CARGO }}
25+
steps:
26+
- run: echo "Bypass GitHub Action Restriction"
27+
publish:
28+
needs:
29+
- pre
30+
uses: ./.github/workflows/publish.yml
31+
with:
32+
path: ${{ needs.pre.outputs.path }}
33+
secrets: inherit

.github/workflows/deploy.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v4
28+
with:
29+
submodules: 'recursive'
2830
- uses: Swatinem/rust-cache@v2
2931
- uses: dtolnay/rust-toolchain@nightly
3032
- uses: actions/configure-pages@v5
3133
- run: |
3234
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
3335
- run: |
34-
cd wasm
35-
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' wasm-pack build --target web --release
36-
cp -r ./pkg ./deploy
36+
cp -r ./assets ./wasm/deploy
37+
cd wasm && RUSTFLAGS='--cfg getrandom_backend="wasm_js"' wasm-pack build --target web --release
38+
cp -r ./pkg ./deploy
3739
- uses: actions/upload-pages-artifact@v3
3840
with:
3941
path: 'wasm/deploy'

.github/workflows/parse.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: parse
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
path:
7+
default: 'Cargo.toml'
8+
required: true
9+
type: string
10+
outputs:
11+
version:
12+
description: "Parsed cargo version for rust project"
13+
value: ${{ jobs.parse.outputs.version }}
14+
name:
15+
description: "Parsed cargo binary name for rust project"
16+
value: ${{ jobs.parse.outputs.name }}
17+
18+
jobs:
19+
parse:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
version: ${{ steps.regex.outputs.version }}
23+
name: ${{ steps.regex.outputs.name }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- id: regex
27+
run: |
28+
version=$(sed -n '0,/version = "\(.*\)"/s//\1/p' $CARGO)
29+
name=$(sed -n '0,/name = "\(.*\)"/s//\1/p' $CARGO)
30+
echo version=$version >> $GITHUB_OUTPUT
31+
echo name=$name >> $GITHUB_OUTPUT
32+
name: Parse Cargo.toml
33+
shell: bash
34+
env:
35+
CARGO: ${{ inputs.path }}

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
path:
7+
default: 'Cargo.toml'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
ready:
13+
uses: ./.github/workflows/parse.yml
14+
with:
15+
path: ${{ inputs.path }}
16+
tag:
17+
needs:
18+
- ready
19+
uses: ./.github/workflows/tag.yml
20+
with:
21+
version: ${{ needs.ready.outputs.version }}
22+
release:
23+
needs:
24+
- tag
25+
uses: ./.github/workflows/release.yml
26+
with:
27+
version: ${{ needs.tag.outputs.version }}
28+
note: "add release for ${{ needs.tag.outputs.version }}"
29+
publish:
30+
uses: ./.github/workflows/build.yml

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: release
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
version:
10+
default: '0'
11+
required: true
12+
type: string
13+
note:
14+
default: 'None'
15+
required: true
16+
type: string
17+
outputs:
18+
tag:
19+
description: "Pushed tag version"
20+
value: ${{ jobs.release.outputs.tag }}
21+
22+
jobs:
23+
release:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
tag: ${{ steps.release.outputs.tag }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- id: check-release
31+
name: Check if release exists
32+
run: |
33+
if gh release view $VERSION &>/dev/null; then
34+
echo "release_exists=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "release_exists=false" >> $GITHUB_OUTPUT
37+
fi
38+
shell: bash
39+
env:
40+
VERSION: ${{ inputs.version }}
41+
42+
- id: release
43+
name: Create or update release
44+
run: |
45+
if [ "$RELEASE_EXISTS" == "true" ]; then
46+
echo "Release with tag $VERSION already exists, overwriting it..."
47+
gh release edit $VERSION --notes "$NOTE"
48+
else
49+
echo "Creating new release with tag $VERSION..."
50+
gh release create $VERSION --notes "$NOTE"
51+
fi
52+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
53+
shell: bash
54+
env:
55+
VERSION: ${{ inputs.version }}
56+
NOTE: ${{ inputs.note }}
57+
RELEASE_EXISTS: ${{ steps.check-release.outputs.release_exists }}

.github/workflows/tag.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: tag
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
version:
10+
default: '0'
11+
required: true
12+
type: string
13+
outputs:
14+
version:
15+
description: "Pushed tag version"
16+
value: ${{ jobs.tag.outputs.version }}
17+
18+
jobs:
19+
tag:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
version: ${{ steps.push.outputs.version }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-tags: true
27+
- id: push
28+
run: |
29+
version="${{ inputs.version }}"
30+
git tag $version && git push --tags || true
31+
echo version=$version >> $GITHUB_OUTPUT
32+
name: Push Tag
33+
shell: bash

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pdf-wasm"
3-
version = "0.0.5"
3+
version = "0.0.6"
44
edition = "2024"
55

66
[dependencies]

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# PDF-WASM
22

3+
<p align="center" width="100%">
4+
<img src="assets/favicon.png" alt="PDF-WASM" style="width: 50%; min-width: 300px; display: block; margin: auto;">
5+
</p>
6+
37
[![CI Status](https://github.com/Mon-ius/PDF-WASM/workflows/build/badge.svg)](https://github.com/Mon-ius/PDF-WASM/actions?query=workflow:deploy)
4-
[![Code Size](https://img.shields.io/github/languages/code-size/Mon-ius/PDF-WASM)](https://github.com/Mon-ius/PDF-WASM)
8+
[![GitHub top language](https://img.shields.io/github/languages/top/Mon-ius/PDF-WASM?logo=rust&label=)](./Cargo.toml#L4)
59
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE)
10+
[![Code Size](https://img.shields.io/github/languages/code-size/Mon-ius/PDF-WASM)](https://github.com/Mon-ius/PDF-WASM)
11+
[![GitHub release (with filter)](https://img.shields.io/github/v/release/Mon-ius/PDF-WASM?logo=github)](https://github.com/Mon-ius/PDF-WASM/releases)
612

7-
## Deploy
13+
> A rust based pdf in-text replace tool, with WASM library export.
814
915
```sh
1016
git clone --depth 1 --branch master --recurse-submodules 'https://github.com/Mon-ius/PDF-WASM'
@@ -23,7 +29,8 @@ git config -f .gitmodules submodule.deps/lopdf.shallow true
2329
```
2430

2531
### Source
26-
[PDF-WASM](https://github.com/Mon-ius/PDF-WASM)
32+
33+
- [PDF-WASM](https://github.com/Mon-ius/PDF-WASM)
2734

2835
### Credits
2936
- [J-F-Liu/lopdf](https://github.com/J-F-Liu/lopdf)

assets/favicon.png

760 KB
Loading

0 commit comments

Comments
 (0)