Skip to content

Commit

Permalink
Update README and build executables
Browse files Browse the repository at this point in the history
  • Loading branch information
djellemah committed Apr 27, 2024
1 parent 7ac2469 commit c840428
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 628 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: build release packages on os

on:
workflow_dispatch: {}
push:
tags: v*
pull_request: {}

# https://cli.github.com/manual/gh_release
# https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: gh create release
run: |
gh release delete ${{ github.ref_name }} --yes
gh release create --latest ${{ github.ref_name }}
env:
GH_TOKEN: ${{ secrets.ACTION_TOKEN }}

# apparently you can't remove v0.1.0.tar.gz and v0.1.0.zip source archives
# - name: gh remove sources
# run: |
# gh release delete-asset ${{ github.ref_name }} ${{ github.ref_name }}.zip --yes
# gh release delete-asset ${{ github.ref_name }} ${{ github.ref_name }}.tar.gz --yes
# env:
# GH_TOKEN: ${{ secrets.ACTION_TOKEN }}

release:
needs: create-release
name: build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
runs-on: windows-latest
# - target: x86_64-unknown-linux-musl
# runs-on: ubuntu-latest
- target: x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
- target: x86_64-apple-darwin
runs-on: macos-latest

runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: compile
run: cargo build --release

- name: upload bin to release
if: ${{ runner.os != 'Windows' }}
run: |
cp target/release/jch jch-${{ matrix.target }}-${{ github.ref_name}}
gh release upload ${{ github.ref_name}} jch-${{ matrix.target }}-${{ github.ref_name}}
env:
GH_TOKEN: ${{ secrets.ACTION_TOKEN }}

# also handle windows .exe files
- name: upload exe to release
if: ${{ runner.os == 'Windows' }}
run: |
cp target/release/jch.exe jch-${{ matrix.target }}-${{ github.ref_name}}.exe
gh release upload ${{ github.ref_name}} jch-${{ matrix.target }}-${{ github.ref_name}}.exe
env:
GH_TOKEN: ${{ secrets.ACTION_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/manual-build.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# To trigger via rest api:
# curl -H "Authorization: token $GITHUB_TOKEN" -d "{\"ref\": \"your-branch-here\"}" https://api.github.com/repos/djellemah/jch/actions/workflows/build.yml/dispatches

name: run tests then build release

# on:
# workflow_dispatch: {}
# push:
# tags: v*
# branches: [test-build]
# pull_request: {}

jobs:
build:
runs-on: ubuntu-latest

env: {}

steps:
- uses: actions/checkout@v4

- name: set up git credentials for cargo
run: |
mkdir -p $XDG_CONFIG_HOME/git
echo https://${{ secrets.ACTION_USER }}:${{ secrets.ACTION_TOKEN }}@github.com > $XDG_CONFIG_HOME/git/credentials
git config --global credential.helper store
git config --global --add credential.https://github.com.helper store
git config --global --add credential.https://github.com.username ${{ secrets.ACTION_USER }}

- name: cache setup
uses: Swatinem/rust-cache@v2

- run: cargo build --tests

release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v4

- name: setup cache
uses: Swatinem/rust-cache@v2

- run: cargo build --tests

- name: package
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
with:
files: target/release/jch
41 changes: 41 additions & 0 deletions .github/workflows/rust-build.yaml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: rust-build release packages

# on:
# workflow_dispatch: {}
# push:
# tags: v*
# branches: [test-build]
# pull_request: {}

jobs:
release:
name: build ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz
- target: x86_64-unknown-linux-gnu
archive: tar.gz
- target: x86_64-apple-darwin
archive: zip
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/rust-build.action@master
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Binary
path: |
${{ steps.compile.outputs.BUILT_ARCHIVE }}
${{ steps.compile.outputs.BUILT_CHECKSUM }}
Loading

0 comments on commit c840428

Please sign in to comment.