Skip to content

Commit 2daf7af

Browse files
Alexander Weberreplicadse
authored andcommitted
do not modify / escape input vars
1 parent 14ee498 commit 2daf7af

File tree

3 files changed

+54
-102
lines changed

3 files changed

+54
-102
lines changed

.complate/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ templates:
66
{{ a.alpha }}
77
values:
88
a.alpha:
9-
env: ALPHA
9+
static: '"test"'
1010
one:
1111
content:
1212
file: ./.complate/templates/arbitraty-template-file.tpl

.github/workflows/release.yml

Lines changed: 52 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,124 +3,75 @@ on:
33
workflow_dispatch:
44
inputs:
55
version:
6-
description: "version number"
6+
description: "version"
77
required: true
88

9-
env:
10-
RELEASE_FILE: RELEASE.txt
11-
129
jobs:
13-
check:
14-
name: check (${{ matrix.name }})
15-
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
include:
19-
- name: "default"
20-
features: ""
21-
- name: "all"
22-
features: --all-features
23-
- name: "backend+ui"
24-
features: --features "backend+ui" --no-default-features
25-
steps:
26-
- uses: actions/checkout@v1
27-
- name: install tools
28-
run: sudo apt-get install build-essential libncurses5-dev libncursesw5-dev
29-
- name: execute tests
30-
run: cargo test ${{ matrix.features }}
31-
- name: build program
32-
run: cargo build ${{ matrix.features }}
33-
- name: run cli tests
34-
working-directory: test
35-
run: sh test-cli.sh
36-
37-
tag:
10+
version:
11+
name: version
3812
if: github.ref == 'refs/heads/master'
39-
needs: check
40-
name: tag and release
4113
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.export.outputs.version }}
16+
upload_url: ${{ steps.releaseExp.outputs.upload_url }}
4217
steps:
43-
- uses: actions/checkout@v1
44-
- name: create release
45-
id: create_release
46-
uses: actions/create-release@latest
47-
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
with:
50-
tag_name: ${{ github.event.inputs.version }}
51-
release_name: ${{ github.event.inputs.version }}
52-
body: |
53-
Release ${{ github.event.inputs.version }}.
54-
draft: false
55-
prerelease: false
56-
- run: printf ${{ steps.create_release.outputs.upload_url }} > ${{ env.RELEASE_FILE }}
57-
- name: upload release data
58-
uses: actions/[email protected]
18+
- id: export
19+
run: 'printf "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT'
20+
- id: release
21+
name: Create Release
22+
uses: ncipollo/[email protected]
5923
with:
60-
name: RELEASE
61-
path: ${{ env.RELEASE_FILE }}
24+
tag: ${{ github.event.inputs.version }}
25+
allowUpdates: true
26+
removeArtifacts: true
27+
makeLatest: true
28+
- id: releaseExp
29+
run: 'printf "upload_url=${{ steps.release.outputs.upload_url }}" >> $GITHUB_OUTPUT'
6230

63-
publish-cratesio:
64-
needs: tag
65-
name: crates.io
31+
crates-io:
32+
name: "crates.io"
33+
if: github.ref == 'refs/heads/master'
6634
runs-on: ubuntu-latest
35+
needs:
36+
- version
6737
steps:
68-
- uses: actions/checkout@v1
69-
- name: get version
70-
id: get_version
71-
run: echo ::set-output name=VERSION::$(git tag --points-at HEAD --sort -version:refname | head -1)
72-
- name: install tools
73-
run: |
74-
sudo apt-get install build-essential libncurses5-dev libncursesw5-dev
38+
- uses: actions/checkout@v3
39+
- name: install rust
40+
run: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
7541
- name: publish
76-
id: publish
7742
run: |
78-
sed 's/version = "0.0.0"/version = "'${{ steps.get_version.outputs.VERSION }}'"/g' Cargo.toml > Cargo.toml.tmp
79-
mv Cargo.toml.tmp Cargo.toml
8043
cargo login ${{ secrets.CRATES_IO_TOKEN }}
44+
sed 's/version = "0.0.0"/version = "'${{ needs.version.outputs.version }}'"/g' Cargo.toml > Cargo.toml.tmp
45+
mv Cargo.toml.tmp Cargo.toml
8146
cargo publish --allow-dirty
8247
83-
publish:
84-
needs: tag
85-
name: publish for ${{ matrix.os }}
86-
runs-on: ${{ matrix.os }}
87-
strategy:
88-
matrix:
89-
include:
90-
- os: macos-latest
91-
target: x86_64-apple-darwin
92-
install: printf ok
93-
- os: ubuntu-latest
94-
target: x86_64-unknown-linux-gnu
95-
install: sudo apt-get install build-essential libncurses5-dev libncursesw5-dev
48+
deb:
49+
name: "deb"
50+
if: github.ref == 'refs/heads/master'
51+
runs-on: ubuntu-latest
52+
needs:
53+
- version
54+
- crates-io
9655
steps:
97-
- uses: actions/checkout@v1
98-
- name: get version
99-
id: get_version
100-
run: echo ::set-output name=VERSION::$(git tag --points-at HEAD --sort -version:refname | head -1)
101-
- name: download release id
102-
uses: actions/[email protected]
103-
with:
104-
name: RELEASE
105-
- name: get release data
106-
id: get_release_data
107-
run: echo ::set-output name=upload_url::$(cat RELEASE/${{ env.RELEASE_FILE }})
108-
- name: install tools
56+
- uses: actions/checkout@v3
57+
- run: |
58+
sudo apt-get install -y curl
59+
- name: install rust
10960
run: |
110-
${{ matrix.install }}
111-
rustup target install ${{ matrix.target }}
112-
- name: build-${{ matrix.target }}
61+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
62+
cargo install cargo-deb
63+
- name: publish
11364
run: |
114-
sed 's/version = "0.0.0"/version = "'${{ steps.get_version.outputs.VERSION }}'"/g' Cargo.toml > Cargo.toml.tmp
65+
sed 's/version = "0.0.0"/version = "'${{ needs.version.outputs.version }}'"/g' Cargo.toml > Cargo.toml.tmp
11566
mv Cargo.toml.tmp Cargo.toml
116-
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target ${{ matrix.target }}
117-
- name: zip
118-
run: cd ./target/${{ matrix.target }}/release && tar -zcvf ${{ matrix.target }}.tar.gz complate
119-
- name: upload asset
120-
uses: svenstaro/upload-release-action@v1-release
67+
cargo deb
68+
- name: Upload Release Asset
69+
id: upload-release-asset
70+
uses: actions/upload-release-asset@v1
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12173
with:
122-
repo_token: ${{ secrets.GITHUB_TOKEN }}
123-
file: ./target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz
124-
asset_name: ${{ matrix.target }}.tar.gz
125-
tag: ${{ steps.get_version.outputs.VERSION }}
126-
overwrite: true
74+
upload_url: ${{ needs.version.outputs.upload_url }}
75+
asset_path: ./target/debian/complate_${{ needs.version.outputs.version }}_amd64.deb
76+
asset_name: complate_${{ needs.version.outputs.version }}_amd64.deb
77+
asset_content_type: application/octet-stream

src/render/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub async fn render(
4848
}
4949

5050
let mut hb = handlebars::Handlebars::new();
51+
hb.register_escape_fn(|s| s.to_owned());
5152
if args.strict {
5253
hb.set_strict_mode(true);
5354
}

0 commit comments

Comments
 (0)