Skip to content

.github/workflows/release.yml #10

.github/workflows/release.yml

.github/workflows/release.yml #10

Workflow file for this run

on:
workflow_dispatch:
inputs:
tag:
description: "Tag of the release - should be in v[0-9]+.[0-9]+.[0.9]+"
required: True
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout repository
with:
fetch-depth: 0
- name: Create artifacts directory
run: mkdir artifacts
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependancies
run: |
pip install requests
pip install GitPython
- name: Generate body
env:
TAG: ${{ github.event.inputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python release.py
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
body_path: ./body
- 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 "${{ github.event.inputs.tag }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
build-release:
name: build-release
needs: ["create-release"]
runs-on: ${{ matrix.os }}
env:
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
MACOSX_DEPLOYMENT_TARGET: 10.9
strategy:
matrix:
build: [linux, linux-static]
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-static
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v3
name: Checkout repository
with:
fetch-depth: 0
- name: Checkout submodule
run: git submodule update --init --recursive
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- 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 release binary
if: matrix.build == 'linux' || matrix.build == 'macos' || matrix.build == 'windows'
uses: actions-rs/cargo@v1
with:
command: build
toolchain: "${{ matrix.rust }}"
args: --target ${{ matrix.target }} --release
- name: Build release binary
if: matrix.build == 'linux-static'
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} --release
- name: Build archive
shell: bash
run: |
if [ "${{ matrix.build }}" = "windows" ]; then
echo "ASSET=target/${{ matrix.target }}/release/ntfs-undelete.exe" >> $GITHUB_ENV
echo "ASSET_NAME=ntfs-undelete-${{ github.event.inputs.tag }}.exe" >> $GITHUB_ENV
else
echo "ASSET=target/${{ matrix.target }}/release/ntfs-undelete" >> $GITHUB_ENV
echo "ASSET_NAME=ntfs-undelete-${{ github.event.inputs.tag }}-${{ matrix.target }}" >> $GITHUB_ENV
fi
- 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 }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream