Skip to content

Commit

Permalink
chore(ci): add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iahmadgad committed Oct 25, 2024
1 parent a006c01 commit 79515a0
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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

0 comments on commit 79515a0

Please sign in to comment.