Skip to content

Create Release Asset #48

Create Release Asset

Create Release Asset #48

Workflow file for this run

name: Create Release Asset
on:
schedule:
- cron: "0 0 * * 0" # weekly
workflow_dispatch:
push:
tags:
'v*'
jobs:
prepare_env:
name: Prepare build version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get latest release
continue-on-error: true
id: cur_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: draft
- name: Set outputs
id: vars
run: |
tag=${GITHUB_REF#refs/tags/*}
sha=$(git rev-parse --short HEAD)
version=$([[ $tag == v* ]] && echo ${tag:1} || echo 0.0.$sha)
cur_ver=$([[ ${{ steps.cur_release.outcome }} == failure ]] && echo v0 || echo ${{ steps.cur_release.outputs.release }})
[[ v$version == $cur_ver ]] && exit 1
prerelease=$([[ $tag == v* ]] && echo false || echo true)
rust_cache=${{ hashFiles('**/rust-toolchain', '**/Cargo.lock') }}
echo "version=$version" >> $GITHUB_ENV
echo "arch=$(dpkg-architecture -q DEB_BUILD_ARCH)" >> $GITHUB_ENV
echo "prerelease=$prerelease" >> $GITHUB_ENV
echo "rust_cache=$rust_cache" >> $GITHUB_ENV
echo "rust_toolchain=$(cat rust-toolchain)" >> $GITHUB_ENV
outputs:
version: ${{ env.version }}
arch: ${{ env.arch }}
prerelease: ${{ env.prerelease }}
rust_cache: ${{ env.rust_cache }}
rust_toolchain: ${{ env.rust_toolchain }}
build:
needs: prepare_env
name: Build and release
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build: [general, webrender]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v2
- name: rust setup
id: rust-setup
run: |
rustup install $(cat rust-toolchain)
rustup component add rustfmt-preview
- name: Cache rust
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
./target
key: ${{ runner.os }}-${{ matrix.build }}-cargo-${{ needs.prepare_env.outputs.rust_cache }}
restore-keys: |
${{ runner.os }}-${{ matrix.build }}-cargo
- name: Build project
if: ${{ matrix.build == 'general' }}
run: |
version=${{ needs.prepare_env.outputs.version }}
bin_version=$version
echo "version=$version" >> $GITHUB_ENV
echo "bin_version=$bin_version" >> $GITHUB_ENV
./build_emacs_ng.sh $bin_version
- name: Build project with webrender
if: ${{ matrix.build == 'webrender' }}
run: |
version=${{ needs.prepare_env.outputs.version }}
bin_version=$version.webrender
echo "version=$version" >> $GITHUB_ENV
echo "bin_version=$bin_version" >> $GITHUB_ENV
./build_emacs_ng.sh $bin_version --with-webrender --with-winit
- name: Reduce cache
continue-on-error: true
run: |
## Reduce Cache
# https://bheisler.github.io/post/efficient-use-of-travis-ci-cache-for-rust/
# Delete loose files in the release/debug directory
sudo find ./target/release -maxdepth 1 -type f -delete
# Delete just meta data
sudo rm -f ./target/.rustc_info.json
# Also delete cargo's registry index. This is updated on every build, but it's
# way cheaper to re-download than the whole cache is.
sudo rm -rf ~/.cargo/registry/index/
- name: Get release
id: get_release_by_tag
uses: jonfriesen/[email protected]
with:
tag_name: v${{ env.version }}
continue-on-error: true
- name: Do Release
if: steps.get_release_by_tag.outcome == 'failure'
id: do_release
uses: ncipollo/release-action@v1
with:
tag: v${{ env.version }}
name: emacs-ng_${{ env.version }}
draft: false
prerelease: ${{ needs.prepare_env.outputs.prerelease }}
artifactErrorsFailBuild: true
artifacts: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
artifactContentType: application/vnd.debian.binary-package
token: ${{ secrets.GITHUB_TOKEN }}
- name: Do upload to release
if: steps.get_release_by_tag.outcome == 'success'
id: upload_release_asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }}
asset_path: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
asset_name: emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
asset_content_type: application/vnd.debian.binary-package