Skip to content

Commit

Permalink
add github release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Van der Jeugt committed Jul 13, 2021
1 parent 5f4150e commit b77f92b
Showing 1 changed file with 163 additions and 0 deletions.
163 changes: 163 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# The MIT License (MIT)
#
# Copyright (c) 2016 Jinzhou Zhang
#
# 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.

# workflow copied from https://github.com/lotabout/skim and modified
name: Publish to Github

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
create-release:
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Get the release version from the tag
run: |
# Apparently, this is the right way to get a tag name. Really?
#
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create Release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.RELEASE_VERSION }}
body: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact
run: echo "${{ env.RELEASE_VERSION }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts

publish-to-github:
name: Publish to Github
needs: ['create-release']
runs-on: ${{matrix.os}}
strategy:
matrix:
build: [linux, arm, arm-v7, macos]
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: arm
os: ubuntu-latest
rust: stable
target: arm-unknown-linux-gnueabihf
cross: true
- build: arm-v7
os: ubuntu-latest
rust: stable
target: armv7-unknown-linux-gnueabihf
cross: true
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install correct toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
use-cross: ${{ matrix.cross }}
override: true

- name: Get release download URL
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"
- name: build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Package Artifacts
run: |
src=$(pwd)
stage=
case $RUNNER_OS in
Linux)
stage=$(mktemp -d)
;;
macOS)
stage=$(mktemp -d -t tmp)
;;
esac
echo "src is: $src"
echo "stage is: $stage"
cp target/${{ matrix.target }}/release/FragGeneScanRs $stage/
cd $stage
ASSET_NAME="FragGeneScanRs-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz"
ASSET_PATH="$src/$ASSET_NAME"
echo "ASSET_NAME=$ASSET_NAME" >> $GITHUB_ENV
echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV
tar czf $ASSET_PATH *
cd $src
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET_PATH }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream

0 comments on commit b77f92b

Please sign in to comment.