Skip to content

Commit

Permalink
even more wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Feb 15, 2024
1 parent 03363a1 commit 6df8269
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 52 deletions.
130 changes: 90 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Rust Multi-Platform Build and Release
name: "Release"

on:
# workflow_run:
# workflows: ["Tag"]
# types:
# - "completed"
push:
tags:
- 'v*.*.*'
Expand All @@ -10,52 +14,98 @@ on:
description: "Tag Name to Build"
required: true

permissions:
contents: "write"

jobs:
build-and-release:
runs-on: ubuntu-latest
get-tag:
name: "Get Tag From Package Version"
runs-on: "ubuntu-latest"
outputs:
pkg-version: ${{ steps.pkg-version.outputs.PKG_VERSION }}
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: "Get tag"
id: "pkg-version"
shell: "bash"
run: |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT
create-release:
name: "Create release"
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: "get-tag"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v4

- name: "Create release"
uses: "taiki-e/create-gh-release-action@v1"
with:
changelog: CHANGELOG.md
branch: "main"
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }}
token: ${{ secrets.BOT_ACCESS_TOKEN }}

upload-assets:
name: "Upload assets to Github releases"
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs:
- "get-tag"
- "create-release"
strategy:
matrix:
include:
- prefix: x86_64-linux
target: x86_64-unknown-linux-gnu
cross: false
- prefix: i686-linux
target: i686-unknown-linux-gnu
cross: true
- prefix: aarch64-linux
target: aarch64-unknown-linux-gnu
cross: true
- os: macos-latest
target: x86_64-apple-darwin
- target: "x86_64-unknown-linux-gnu"
os: "ubuntu-latest"
- target: "x86_64-unknown-linux-musl"
os: "ubuntu-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: "Check out the repo"
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
- name: "Upload Binaries"
uses: "taiki-e/upload-rust-binary-action@v1"
with:
toolchain: stable
bin: "tinty"
target: ${{ matrix.target }}
profile: minimal
override: true
archive: $bin-${{ matrix.target }}
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }}
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Build Release
run: cargo build --release --target ${{ matrix.target }}

- name: Archive Production Artifacts
run: |
zip -r tinty-${{ matrix.target }}-${{ github.ref_name }}.zip ./target/${{ matrix.target }}/release/
shell: bash
# push-to-registry:
# name: "Push Docker image to Docker Hub"
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# needs:
# - "get-tag"
# - "upload-assets"
# runs-on: "ubuntu-latest"
# steps:
# - name: "Check out the repo"
# uses: actions/checkout@v3

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: tinty-${{ matrix.target }}-${{ github.ref_name }}
path: tinty-${{ matrix.target }}-${{ github.ref_name }}.zip

- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: tinty-*-${{ github.ref_name }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: "Log in to Docker Hub"
# uses: "docker/login-action@v2"
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: "Extract metadata (tags, labels) for Docker"
# id: "meta"
# uses: "docker/metadata-action@v4"
# with:
# images: "tinted-theming/tinty"

# - name: "Build and push Docker image"
# uses: "docker/build-push-action@v3"
# with:
# context: .
# push: true
# tags: tinted-theming/tinty:latest,tinted-theming/tinty:v${{ needs.get-tag.outputs.pkg-version }}
# labels: ${{ steps.meta.outputs.labels }}
83 changes: 71 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Run tests
name: "Test"

on:
workflow_dispatch:
push:
Expand All @@ -7,18 +8,76 @@ on:
pull_request:

jobs:
run:
runs-on: ubuntu-latest
check:
name: "Cargo check"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3

- uses: "actions-rs/toolchain@v1"
with:
profile: "minimal"
toolchain: "stable"
override: true

- uses: "actions-rs/cargo@v1"
with:
command: "check"

test:
name: "Cargo test"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3

- uses: "actions-rs/toolchain@v1"
with:
profile: "minimal"
toolchain: "stable"
override: true

- uses: "actions-rs/cargo@v1"
with:
command: "test"

fmt:
name: "Cargo format"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3

- uses: "actions-rs/toolchain@v1"
with:
profile: "minimal"
toolchain: "stable"
override: true

- run: "rustup component add rustfmt"

- uses: "actions-rs/cargo@v1"
with:
command: "fmt"
args: "--all -- --check"

clippy:
name: "Cargo clippy"
runs-on: "ubuntu-latest"
steps:
# Checkout repo
- name: Fetch the repository code
uses: actions/checkout@v4
- name: "Check out the repo"
uses: actions/checkout@v3

- name: Deny banned crates and licenses
uses: EmbarkStudios/cargo-deny-action@v1
- uses: "actions-rs/toolchain@v1"
with:
profile: "minimal"
toolchain: "stable"
override: true

- name: Build Docker image
run: docker build . -t tinty
- run: "rustup component add clippy"

- name: Run Docker container
run: docker run tinty
- uses: "actions-rs/cargo@v1"
with:
command: "clippy"
args: "-- -D warnings"

0 comments on commit 6df8269

Please sign in to comment.