ci: Add release build (#106)

* ci: Build target aware

* ci: Add release.yml
This commit is contained in:
Esteban Blanc 2020-12-21 18:46:09 +01:00
parent 09af371589
commit 1ddbe1702e
2 changed files with 74 additions and 4 deletions

View file

@ -22,22 +22,46 @@ jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v2
- name: Rustup setup
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ matrix.target }}
- name: Unit tests
run: |
cargo test
cargo test --target ${{ matrix.target }}
build:
runs-on: ubuntu-latest
needs: [lint, tests]
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v2
- name: Rustup setup
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ matrix.target }}
- name: Check
run: |
cargo check
cargo check --target ${{ matrix.target }}
- name: Build
run: |
cargo build
cargo build --target ${{ matrix.target }}

46
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,46 @@
name: Release upload artifact
on:
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v2
- name: Rustup setup
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ matrix.target }}
- name: Build release
run: |
cargo build --release --target ${{ matrix.target }}
- name: Retrive tag
id: retrive_tag
run: |
echo "##[set-output name=tag;]$(echo ${GITHUB_REF} | cut -d / -f3)"
- name: Find upload URL
id: upload_url
run: |
echo "##[set-output name=url;] $(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/skallwar/suckit/releases/tags/${{ steps.retrive_tag.outputs.tag }} | jq .upload_url -r)"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.upload_url.outputs.url}}
asset_path: ./target/${{ matrix.target }}/release/suckit
asset_name: suckit-${{ steps.retrive_tag.outputs.tag }}-${{ matrix.target }}
asset_content_type: application/x-elf