Skip to content

Commit

Permalink
ci: update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Jan 25, 2024
1 parent e7239b0 commit 75c73ac
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 75 deletions.
120 changes: 95 additions & 25 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,118 @@
name: Publish
name: Publish latest

on:
push:
branches:
- main
tags:
- '*'

env:
CARGO_TERM_COLOR: always

jobs:
binary:
name: Publish binary for ${{ matrix.os }}
upload_license:
name: Upload License
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/upload-artifact@v3
with:
name: LICENSE
path: LICENSE

build:
name: Build onagre ${{ matrix.os }}-${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# This should work with only the `include`s but it currently doesn't because of this bug:
# https://github.community/t5/How-to-use-Git-and-GitHub/GitHub-Actions-Matrix-options-dont-work-as-documented/td-p/29558
target: [ x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, armv7-unknown-linux-musleabihf ]
include:
- os: ubuntu-22.04
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-22.04
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf

steps:
- uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
rust-version: stable
cache-all-crates: "true"
key: "${{ matrix.os }}-${{ matrix.target }}"

- name: Install libssl-dev
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: sudo apt-get update && sudo apt-get install cmake mingw-w64
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libxkbcommon-dev libvulkan1 mesa-vulkan-drivers libegl1-mesa-dev
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release --locked

- uses: actions/checkout@v1
- name: Build
run: ci/action.sh release ${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/onagre

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
upload_to_release:
needs: [ build, upload_license]
name: Publish onagre binaries
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/download-artifact@v3
with:
path: ~/artifacts

- name: Copy artifacts to archive
run: |
mkdir x86_64-unknown-linux-musl
cp -r /home/runner/artifacts/x86_64-unknown-linux-musl/onagre x86_64-unknown-linux-musl/onagre
chmod +x -R x86_64-unknown-linux-musl/onagre
cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-unknown-linux-musl/
tar -czf onagre-x86_64-unknown-linux-musl.tar.gz x86_64-unknown-linux-musl/*
mkdir x86_64-unknown-linux-gnu
cp -r /home/runner/artifacts/x86_64-unknown-linux-gnu/onagre x86_64-unknown-linux-gnu/onagre
chmod +x -R x86_64-unknown-linux-gnu/onagre
cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-unknown-linux-gnu/
tar -czf onagre-x86_64-unknown-linux-gnu.tar.gz x86_64-unknown-linux-gnu/*
mkdir armv7-unknown-linux-musleabihf
cp -r /home/runner/artifacts/armv7-unknown-linux-musleabihf/onagre armv7-unknown-linux-musleabihf/onagre
chmod +x -R armv7-unknown-linux-musleabihf/onagre
cp -r /home/runner/artifacts/LICENSE/LICENSE armv7-unknown-linux-musleabihf/
tar -czf onagre-armv7-unknown-linux-musleabihf.tar.gz armv7-unknown-linux-musleabihf/*
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/tar/onagre.tar.gz
file: onagre-x86_64-unknown-linux-musl.tar.gz
tag: ${{ github.ref }}
asset_name: onagre-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
asset_name: onagre-${{ github.ref_name }}-x86_64-unknown-linux-musl.tar.gz

- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: onagre-armv7-unknown-linux-musleabihf.tar.gz
tag: ${{ github.ref_name }}
asset_name: onagre-${{ github.ref_name }}-armv7-unknown-linux-musleabihf.tar.gz

- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: onagre-armv7-unknown-linux-musleabihf.tar.gz
tag: ${{ github.ref_name }}
asset_name: onagre-${{ github.ref_name }}-armv7-unknown-linux-musleabihf.tar.gz


2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
git config --global user.name github-actions
- name: Conventional commit check
uses: cocogitto/cocogitto-action@v3.5
uses: cocogitto/cocogitto-action@v3
with:
git-user: 'github-actions'
git-user-email: 'github-actions@github.com'
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
workflow_dispatch:

jobs:
release:
name: SemVer release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{secrets.RELEASE_TOKEN}}

- run: |
git config user.name github-actions
git config user.email github-actions@github.com
git config --global user.email github-actions@github.com
git config --global user.name github-actions
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- run:
cargo install cargo-edit

- run:
cargo login ${{secrets.CARGO_TOKEN}}

- name: SemVer release
id: release
uses: cocogitto/cocogitto-action@v3
with:
check-latest-tag-only: true
release: true
git-user: 'github-actions'
git-user-email: 'github-actions@github.com'

- name: Generate Changelog
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md

- name: Upload github release
uses: softprops/action-gh-release@v1
with:
body_path: GITHUB_CHANGELOG.md
tag_name: ${{ steps.release.outputs.version }}

# - name: vuepress-deploy
# uses: jenkey2011/vuepress-deploy@master
# env:
# COMMIT_MESSAGE: "chore: update gh-pages"
# ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BUILD_SCRIPT: cd docs && yarn && yarn docs:build
# BUILD_DIR: website/.vuepress/dist/
48 changes: 0 additions & 48 deletions ci/action.sh

This file was deleted.

1 change: 0 additions & 1 deletion rustfmt.toml

This file was deleted.

0 comments on commit 75c73ac

Please sign in to comment.