spotube/.circleci/config.yml
2023-11-21 20:11:08 +06:00

178 lines
5.6 KiB
YAML

version: 2.1
orbs:
gh: circleci/github-cli@2.2.0
jobs:
flutter_linux_arm:
machine:
image: ubuntu-2204:current
resource_class: arm.medium
parameters:
version:
type: string
default: 3.1.1
channel:
type: enum
enum:
- release
- nightly
default: release
github_run_number:
type: string
default: "0"
dry_run:
type: boolean
default: true
steps:
- checkout
- gh/setup
- run:
name: Get current date
command: |
echo "export CURRENT_DATE=$(date +%Y-%m-%d)" >> $BASH_ENV
- run:
name: Install dependencies
command: |
sudo apt-get update -y
sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libunwind-dev locate patchelf gir1.2-appindicator3-0.1 libappindicator3-1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev mpv libmpv-dev zip rpm
- run:
name: Install Flutter
command: |
git clone https://github.com/flutter/flutter.git
cd flutter && git checkout stable && cd ..
export PATH="$PATH:`pwd`/flutter/bin"
flutter precache
flutter doctor -v
- run:
name: Install AppImageTool
command: |
wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage"
chmod +x appimagetool
mv appimagetool flutter/bin
- persist_to_workspace:
root: flutter
paths:
- .
- when:
condition:
equal: [<< parameters.channel >>, nightly]
steps:
- run:
name: Replace pubspec version and BUILD_VERSION Env (nightly)
command: |
curl -sS https://webi.sh/yq | sh
yq -i '.version |= sub("\+\d+", "+<< parameters.channel >>.")' pubspec.yaml
yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml
echo 'export BUILD_VERSION="<< parameters.version >>+<< parameters.channel >>.<< parameters.github_run_number >>"' >> $BASH_ENV
- when:
condition:
equal: [<< parameters.channel >>, release]
steps:
- run: echo 'export BUILD_VERSION="<< parameters.version >>"' >> $BASH_ENV
- run:
name: Generate .env file
command: |
echo "SPOTIFY_SECRETS=${SPOTIFY_SECRETS}" >> .env
- run:
name: Replace Version in files
command: |
sed -i 's|%{{APPDATA_RELEASE}}%|<release version="${BUILD_VERSION}" date="${CURRENT_DATE}" />|' linux/com.github.KRTirtho.Spotube.appdata.xml
echo "build_arch: aarch64" >> linux/packaging/rpm/make_config.yaml
- run:
name: Build secrets
command: |
export PATH="$PATH:`pwd`/flutter/bin"
flutter config --enable-linux-desktop
flutter pub get
dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns
- run:
name: Build Flutter app
command: |
export PATH="$PATH:`pwd`/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
dart pub global activate flutter_distributor
alias dpkg-deb="dpkg-deb --Zxz"
flutter_distributor package --platform=linux --targets=deb
flutter_distributor package --platform=linux --targets=appimage
flutter_distributor package --platform=linux --targets=rpm
- when:
condition:
equal: [<< parameters.channel >>, nightly]
steps:
- run: make tar VERSION=nightly ARCH=arm64 PKG_ARCH=aarch64
- when:
condition:
equal: [<< parameters.channel >>, release]
steps:
- run: make tar VERSION=${BUILD_VERSION} ARCH=arm64 PKG_ARCH=aarch64
- run:
name: Move artifacts
command: |
mkdir bundle
mv build/spotube-linux-*-aarch64.tar.xz bundle/
mv dist/**/spotube-*-linux.deb bundle/Spotube-linux-aarch64.deb
mv dist/**/spotube-*-linux.rpm bundle/Spotube-linux-aarch64.rpm
mv dist/**/spotube-*-linux.AppImage bundle/Spotube-linux-aarch64.AppImage
zip -r Spotube-linux-aarch64.zip bundle
- store_artifacts:
path: Spotube-linux-aarch64.zip
- when:
condition:
and:
- equal: [<< parameters.dry_run >>, false]
- equal: [<< parameters.channel >>, release]
steps:
- run:
name: Upload to release (release)
command: gh release upload v<< parameters.version >> bundle/* --clobber
- when:
condition:
and:
- equal: [<< parameters.dry_run >>, false]
- equal: [<< parameters.channel >>, nightly]
steps:
- run:
name: Upload to release (nightly)
command: gh release upload nightly bundle/* --clobber
parameters:
GHA_Actor:
type: string
default: ""
GHA_Action:
type: string
default: ""
GHA_Event:
type: string
default: ""
GHA_Meta:
type: string
default: ""
workflows:
build_flutter_for_arm_workflow:
when: << pipeline.parameters.GHA_Action >>
jobs:
- flutter_linux_arm:
context:
- org-global
- GITHUB_CREDS