diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..23b161b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,42 @@ +name: Create release +on: + workflow_dispatch: + inputs: + version: + description: "The release name, something like vX.X.X" + required: true +env: + TARGET_VERSION: ${{ github.event.inputs.version }} +jobs: + release: + name: Create release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: | + CRATE_VERSION=$(cat Cargo.toml | grep ^version | awk '{ print $3 }' | tr -d '"') + CRATE_VERSION=v${CRATE_VERSION} + echo version in Cargo.toml is $CRATE_VERSION + echo version in workflow is $TARGET_VERSION + if [ "$CRATE_VERSION" = "$TARGET_VERSION" ]; then + exit 0 + else + exit 1 + fi + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - run: cargo test --locked --all-features --release + - run: cargo install cargo-deb + - run: cargo deb + - run: cargo install cargo-generate-rpm + - run: cargo generate-rpm + - run: mv target/release/nuq target/release/nuq_${TARGET_VERSION} + - uses: ncipollo/release-action@v1 + with: + artifacts: "target/release/nuq_${{ github.event.inputs.version }},target/debian/*.deb,target/generate-rpm/*.rpm" + artifactErrorsFailBuild: true + commit: ${{ github.sha }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + tag: ${{ github.event.inputs.version }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index fea3a21..daabfa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,10 @@ serde-transcode = "1.1" serde_yaml = "0.9" syntect = "5.0" toml = "0.5" + +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/nuq", dest = "/usr/bin/nuq", mode = "0755" }, + { source = "LICENSE", dest = "/usr/share/doc/nuq/LICENSE", doc = true, mode = "0644" }, + { source = "README.md", dest = "/usr/share/doc/nuq/README.md", doc = true, mode = "0644" } +]