CI: add a release task

This commit is contained in:
Frank Denis 2021-02-16 01:02:12 +01:00
parent 03581234b5
commit 30abc95e48
2 changed files with 81 additions and 3 deletions

74
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,74 @@
name: Release
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- uses: actions/checkout@master
- uses: hecrj/setup-rust-action@master
with:
rust-version: stable
- name: Check Cargo availability
run: cargo --version
- name: Check Rustup default toolchain
run: rustup default | grep stable
- name: Install cargo-deb
run: cargo install --debug cargo-deb
- name: Release build
run: |
env RUSTFLAGS="-C link-arg=-s" cargo build --release
mkdir doh-proxy
mv target/release/doh-proxy doh-proxy/
cp README.md localhost.pem doh-proxy/
tar cJpf doh-proxy_${{ steps.get_version.outputs.VERSION }}_linux-x86_64.tar.bz2 doh-proxy
- name: Debian package
run: |
cargo deb
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
- name: Upload Debian package
id: upload-release-asset-debian
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: "doh-proxy_${{ steps.get_version.outputs.VERSION }}_amd64.deb"
asset_path: "target/debian/doh-proxy_${{ steps.get_version.outputs.VERSION }}_amd64.deb"
asset_content_type: application/x-debian-package
- name: Upload tarball
id: upload-release-asset-tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: "doh-proxy_${{ steps.get_version.outputs.VERSION }}_linux-x86_64.tar.bz2"
asset_path: "doh-proxy_${{ steps.get_version.outputs.VERSION }}_linux-x86_64.tar.bz2"
asset_content_type: application/x-tar