Skip to content

Commit

Permalink
Added release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-mcdaniel committed Jun 14, 2023
1 parent 16c092d commit 65f2e71
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and upload binaries to release

# copied and modified from https://github.com/Aloso/colo/blob/main/.github/workflows/release.yml

# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
# https://mateuscosta.me/rust-releases-with-github-actions

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

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
# Note this. We are going to use that in further jobs.
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Set variables
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- 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: false
prerelease: false
body: |
This is a new release of Sage. [Read the changelog here (if available for this version)](https://github.com/adam-mcdaniel/sage/blob/${{ steps.vars.outputs.tag }}/CHANGELOG.md).
If you're running on Linux, macOS or Windows, you can probably use one of the binaries below.
release_assets:
name: Release assets
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
file_ending: ''
- os: macos-latest
platform: macos
file_ending: ''
- os: windows-latest
platform: windows
file_ending: '.exe'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Print information
run: |
rustup show active-toolchain
rustc --version
cargo tree
- name: Set variables
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build project
run: cargo build --release --locked

- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: sage_${{ matrix.platform }}_${{ steps.vars.outputs.tag }}${{ matrix.file_ending }}
asset_path: target/release/sage${{ matrix.file_ending }}
asset_content_type: application/octet-stream

0 comments on commit 65f2e71

Please sign in to comment.