-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from duskmoon314/release-action
ci: auto release when push to main
- Loading branch information
Showing
2 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters