Skip to content

Commit

Permalink
ci: add publishing of the debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
chevdor committed Jun 16, 2021
1 parent f3e6937 commit ae9bc49
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/quick-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
name: Quick check

on:
push
push:
tags-ignore:
- v*

jobs:
quick_check:
Expand Down
92 changes: 58 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@ on:
- "v*"

jobs:
setup:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get-refs.outputs.tag }}
version: ${{ steps.get-refs.outputs.version }}
steps:
- uses: actions/checkout@v2
# setup:
# runs-on: ubuntu-latest
# outputs:
# tag: ${{ steps.get-refs.outputs.tag }}
# version: ${{ steps.get-refs.outputs.version }}
# steps:
# - uses: actions/checkout@v2

- name: Extract refs
id: get-refs
run: |
echo GITHUB_REF=$GITHUB_REF
TAG=${GITHUB_REF/refs\/tags\//}
# VERSION=${GITHUB_REF#refs/*/}
VERSION=${GITHUB_REF/refs\/tags\/v/}
echo ::debug::setup TAG: $TAG
echo ::debug::setup VERSION: $VERSION
# - name: Extract refs
# id: get-refs
# run: |
# echo GITHUB_REF=$GITHUB_REF
# TAG=${GITHUB_REF/refs\/tags\//}
# # VERSION=${GITHUB_REF#refs/*/}
# VERSION=${GITHUB_REF/refs\/tags\/v/}
# echo ::debug::setup TAG: $TAG
# echo ::debug::setup VERSION: $VERSION

echo "::set-output name=tag::$TAG"
echo "::set-output name=version::$VERSION"
# echo "::set-output name=tag::$TAG"
# echo "::set-output name=version::$VERSION"

linux:
needs: setup
env:
TARGET_DIR: target/release

Expand All @@ -41,7 +40,6 @@ jobs:
override: true
components: rustfmt, clippy
- uses: actions/checkout@v2

- name: Install cargo deb
uses: actions-rs/cargo@v1
with:
Expand All @@ -51,17 +49,16 @@ jobs:
- name: Build debian package
shell: bash
run: |
cargo deb -p tera-cli
cargo deb -p tera-cli -o "tera-cli_linux_amd64.deb"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: tera-cli-linux_amd64-${{ needs.setup.outputs.tag }}
path: |
target/debian/*.deb
name: linux
path: "tera-cli_linux_amd64.deb"

create_draft:
needs: ["linux", "setup"]
needs: ["linux"]
name: Create Draft
runs-on: ubuntu-latest
outputs:
Expand All @@ -70,35 +67,62 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Get Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v2
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
- uses: actions/download-artifact@v2

- name: Generate changelog
id: change_log
run: |
OUT=`git log $(git describe --tags --abbrev=0)..HEAD --oneline`
echo "::set-output name=changes::$OUT"
JSON=$(git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/')
echo "::set-output name=changes::$JSON"
- name: Create Draft Release
id: create_release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Srtool ${{ needs.setup.outputs.tag }}
tag_name: ${{ env.RELEASE_VERSION }}-${{ env.SHORT_SHA }}
release_name: Tera ${{ env.RELEASE_VERSION }} (${{ env.SHORT_SHA }})
body: |
# Description
You can find the changelogs below.
# Downloads
Download the binary for your OS from below:
- **Linux**
- [deb package](https://github.com/chevdor/tera-cli/releases/download/${{ needs.setup.outputs.tag }}/tera-cli-linux_amd64-${{ needs.setup.outputs.tag }}.deb)
- [deb package](https://github.com/chevdor/tera-cli/releases/download/${{ env.RELEASE_VERSION }}/linux/tera-cli_linux_amd64.deb)
# Release Highlights
----
These were the highlights. Check below for the full changelog :point_down:
${{ steps.change_log.outputs.changes }}
draft: true
publish-binaries:
runs-on: ubuntu-latest
needs: ["create_draft"]
steps:
- uses: actions/checkout@v2
- name: Get Release Version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
- uses: actions/download-artifact@v2
- name: Upload binaries
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_draft.outputs.asset_upload_url }}
asset_path: "linux/tera-cli_linux_amd64.deb"
asset_name: "tera-cli_linux_amd64.deb"
asset_content_type: application/vnd.debian.binary-package
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ authors = ["chevdor <[email protected]>"]
edition = "2018"
name = "tera-cli"
version = "0.1.0"
description = "A command line utility written in Rust to render templates from json|toml|yaml && ENV, using the tera templating engine"
readme = "README.md"
license = "MIT"

[dependencies]
clap = "3.0.0-beta.2"
Expand Down
2 changes: 1 addition & 1 deletion Formula/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: Tera
site: https://github.com
repo: chevdor/tera-cli
archive: "{{ name }}-mac-v1.2.3.tar.gz"
description: A command line utility written in Rust to render templates using the tera templating engine
description: A command line utility written in Rust to render templates from json|toml|yaml && ENV, using the tera templating engine
version: 1.2.3
sha256: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2021 - Wilfried Kopp aka. Chevdor <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit ae9bc49

Please sign in to comment.