Skip to content

Commit

Permalink
add ci and cd scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
alanoliveira committed Oct 30, 2023
1 parent fe58c84 commit c78b84a
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Continuous Deployment

on:
push:
tags:
- "v*.*.*"

jobs:
publish:
name: Publishing for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
rust: [stable]
include:
- os: macos-latest
artifact_prefix: macos
target: x86_64-apple-darwin
binary_postfix: ""
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
binary_postfix: ""
- os: windows-latest
artifact_prefix: windows
target: x86_64-pc-windows-msvc
binary_postfix: ".exe"

steps:
- name: Installing Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: Installing needed macOS dependencies
if: matrix.os == 'macos-latest'
run: brew install sdl2
- name: Installing needed Windows dependencies
if: matrix.os == 'windows-latest'
run: |
Invoke-WebRequest -Uri "https://github.com/libsdl-org/SDL/releases/download/release-2.28.4/SDL2-devel-2.28.4-VC.zip" `
-OutFile SDL2-devel-2.28.4-VC.zip
7z x SDL2-devel-2.28.4-VC.zip
Copy-Item "SDL2-2.28.4\lib\x64\*" "C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib"
- name: Installing needed Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y -qq
sudo apt-get install -y libsdl2-dev
- name: Checking out sources
uses: actions/checkout@v3
- name: Running cargo build
uses: actions-rs/cargo@v1
with:
command: build
toolchain: ${{ matrix.rust }}
args: --release --target ${{ matrix.target }}

- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
BINARY_NAME=sunrest${{ matrix.binary_postfix }}
strip $BINARY_NAME
RELEASE_NAME=sunrest-${{ matrix.artifact_prefix }}
if [[ ${{ runner.os }} == 'Windows' ]]; then
7z a -tzip $RELEASE_NAME.zip $BINARY_NAME '/c/Users/runneradmin/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/lib/SDL2.dll'
certutil -hashfile $RELEASE_NAME.zip sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
else
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
fi
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/sunrest-${{ matrix.artifact_prefix }}.tar.gz
target/${{ matrix.target }}/release/sunrest-${{ matrix.artifact_prefix }}.zip
target/${{ matrix.target }}/release/sunrest-${{ matrix.artifact_prefix }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Continuous Integration

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
NES_TEST_ROMS_REF: 95d8f621ae55cee0d09b91519a8989ae0e64753b
NES_TEST_ROMS_PATH: "${{ github.workspace }}/tmp/nes-test-roms"

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- run: |
sudo apt-get update -y -qq
sudo apt-get install -y libsdl2-dev
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: actions/checkout@v3
with:
repository: christopherpow/nes-test-roms
path: ${{ env.NES_TEST_ROMS_PATH }}
ref: "${{ env.NES_TEST_ROMS_REF }}"
- uses: actions-rs/cargo@v1
with:
command: test
args: --verbose -- --include-ignored

fmt:
name: Fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy

release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: rust
package-name: sunrest

0 comments on commit c78b84a

Please # to comment.