chore(ci): add publish workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: The tag to publish | |
required: true | |
push: | |
tags: [ 'v*.*.*' ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- aarch64-linux-android # 64-bit ARM | |
- armv7-linux-androideabi # 32-bit ARM | |
- i686-linux-android # 32-bit x86 | |
- x86_64-linux-android # 64-bit x86 | |
- arm-linux-androideabi # 32-bit ARM (older ABI) | |
- thumbv7neon-linux-androideabi # 32-bit ARM with NEON | |
name: Build Release - ${{ matrix.target }} | |
steps: | |
- name: Set version variable | |
run: | | |
if [ -n "${{ github.event.inputs.tag }}" ]; then | |
version="${{ github.event.inputs.tag }}" | |
else | |
version="${{ github.ref }}" | |
fi | |
echo "version=${version#v}" >> $GITHUB_ENV | |
- name: Set arch variable | |
run: | | |
arch_alias() { | |
case $1 in | |
"aarch64-linux-android") | |
echo "aarch64" | |
;; | |
"i686-linux-android") | |
echo "i686" | |
;; | |
"x86_64-linux-android") | |
echo "x86_64" | |
;; | |
"arm-linux-androideabi") | |
echo "arm" | |
;; | |
*) | |
echo "Invalid architecture name" | |
;; | |
esac | |
} | |
arch=$(arch_alias ${{ matrix.target }}) | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Cache Deps & Bins | |
uses: Swatinem/rust-cache@v2 | |
- name: Install cross | |
shell: bash | |
run: | | |
if ! command -v cross &> /dev/null; then | |
echo "cross not found, installing..." | |
cargo install cross --git https://github.com/cross-rs/cross | |
else | |
echo "cross already installed, skipping installation." | |
fi | |
- name: Build - ${{ matrix.target }} | |
shell: bash | |
run: cross build --target=${{ matrix.target }} --release | |
- name: Build Termux deb package | |
shell: bash | |
run: ./build_deb -v ${{ version }} -a ${{ arch }} | |
- name: Upload Termux deb package artifact | |
with: | |
name: ${{ matrix.target }} | |
path: ./deb/termux-clock_${{ version }}_${{ arch }}.deb | |
publish: | |
name: Publish to GitHub Releases | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
target: | |
- aarch64-linux-android # 64-bit ARM | |
- armv7-linux-androideabi # 32-bit ARM | |
- i686-linux-android # 32-bit x86 | |
- x86_64-linux-android # 64-bit x86 | |
- arm-linux-androideabi # 32-bit ARM (older ABI) | |
- thumbv7neon-linux-androideabi # 32-bit ARM with NEON | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.tag || github.ref }} # Ensure it checks out the correct tag | |
- name: Download Termux package artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.target }} | |
- name: Publish release | |
uses: ghalactic/github-release-from-tag@v5 | |
with: | |
generateReleaseNotes: true | |
assets: | | |
- path: *.deb |