Skip to content

Commit

Permalink
Merge pull request #36 from duskmoon314/release-action
Browse files Browse the repository at this point in the history
ci: auto release when push to main
  • Loading branch information
luojia65 authored Oct 17, 2022
2 parents 7300658 + b129c38 commit 6818eb7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: release
on:
push:
branches:
- main
tags:
- v*.*.*
workflow_dispatch:

jobs:
build:
strategy:
matrix:
mode: [release, debug]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: riscv64imac-unknown-none-elf
override: true

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.mode }}

- name: Build (release mode)
if: matrix.mode == 'release'
run: cargo make

- name: Build (debug mode)
if: matrix.mode == 'debug'
run: cargo make --debug

- name: Compress and Rename Artifact
run: |
gzip -c target/riscv64imac-unknown-none-elf/${{ matrix.mode }}/rustsbi-qemu.bin > rustsbi-qemu-${{ matrix.mode }}.gz
zip rustsbi-qemu-${{ matrix.mode }}.zip target/riscv64imac-unknown-none-elf/${{ matrix.mode }}/rustsbi-qemu.bin
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: rustsbi-qemu-${{ matrix.mode }}
path: |
rustsbi-qemu-${{ matrix.mode }}.gz
rustsbi-qemu-${{ matrix.mode }}.zip
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: List Artifacts
run: ls -R ./artifacts

- name: Set current date as environment variable
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Check if pre-release
id: check
run: |
if [[ $GITHUB_REF =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT
fi
- name: Get Changelog
id: changelog-reader
uses: mindsers/[email protected]
with:
version: ${{ (steps.check.outputs.PRE_RELEASE && 'Unreleased') || github.ref_name }}

- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.changelog-reader.outputs.version }}
name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }}
body: ${{ steps.changelog-reader.outputs.changes }}
prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }}
target_commitish: ${{ github.sha }}
files: |
artifacts/**/*
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [Unreleased]

### Added

Expand Down

0 comments on commit 6818eb7

Please sign in to comment.