Skip to content

🏷️ v0.1.3

🏷️ v0.1.3 #6

Workflow file for this run

name: Release
on:
push:
tags:
- "*"
env:
FLUTTER_VERSION: "3.13.7"
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version from pubspect.yaml
id: get_version
run: |
VERSION=$(sed -n 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' pubspec.yaml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Get flutter dependencies
run: flutter pub get
- name: Build generated files
run: flutter pub run build_runner build -d
- name: Upload updated lib files with generated code
uses: actions/upload-artifact@v3
with:
name: lib-files
path: ./lib/*
build_tar:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download lib files
uses: actions/download-artifact@v3
with:
name: lib-files
path: ./lib
- name: Install linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libgtk-3-dev ninja-build libayatana-appindicator3-dev keybinder-3.0
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Get flutter dependencies
run: flutter pub get
- name: Compile linux
run: flutter build linux
- name: Create tar.gz archive
run: |
cd build/linux/x64/release/bundle
tar -czvf ../../../../../result.tar.gz *
- name: Upload tar.gz archive
uses: actions/upload-artifact@v3
with:
name: tar-gz-result
path: ./*.tar.gz
build_deb:
needs: build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Download generated files
uses: actions/download-artifact@v3
with:
name: lib-files
path: lib
- name: Install linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libgtk-3-dev ninja-build libayatana-appindicator3-dev keybinder-3.0
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Enable dart_distributor
run: dart pub global activate flutter_distributor
- name: Update PATH
run: echo 'export PATH="$PATH:$HOME/.pub-cache/bin"' >> ~/.bashrc
- name: Build deb package
run: flutter_distributor package --platform linux --targets deb
- name: Find deb file
id: find_deb
run: |
VERSION=${{ needs.build.outputs.version }}
DEB_PATH=$(find dist -name "metranslate-$VERSION*-linux.deb")
echo "deb_path=$DEB_PATH" >> $GITHUB_OUTPUT
- name: Check if deb file exists
id: check_file
run: |
if [[ ! -f "${{ steps.find_deb.outputs.deb_path }}" ]]; then
echo "File not found: ${{ steps.find_deb.outputs.deb_path }}"
exit 1
fi
- name: Upload deb file
uses: actions/upload-artifact@v3
with:
name: deb-result
path: ${{ steps.find_deb.outputs.deb_path }}
build_windows_zip:
needs: build
runs-on: windows-latest
steps:
- name: Fix long file paths
run: git config --system core.longpaths true
- uses: actions/checkout@v4
- name: Download generated files
uses: actions/download-artifact@v3
with:
name: lib-files
path: lib
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Dependencies
run: flutter pub get
- name: Compile for Windows
run: flutter build windows
- name: Zip compiled files
run: Compress-Archive -Path build/windows/runner/Release/* -DestinationPath metranslate.zip
- name: Upload zip
uses: actions/upload-artifact@v3
with:
name: windows-zip-result
path: metranslate.zip
release:
needs: [build, build_tar, build_deb, build_windows_zip]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Draft release
id: draft_release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ needs.build.outputs.version }}
name: v${{ needs.build.outputs.version }}
# TAR.GZ
- name: Download tar.gz file
uses: actions/download-artifact@v3
with:
name: tar-gz-result
path: tar-gz-result
- name: List files in tar.gz-directory
run: ls -l tar-gz-result
- name: Copy tar.gz file to root
run: cp tar-gz-result/* result.tar.gz
- name: Upload Release Asset (tar.gz)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.draft_release.outputs.upload_url }}
asset_path: result.tar.gz
asset_name: metranslate-${{ needs.build.outputs.version }}-linux-x86-64.tar.gz
asset_content_type: application/gzip
# DEB
- name: Download deb file
uses: actions/download-artifact@v3
with:
name: deb-result
path: deb-result
- name: Copy deb file to root
run: cp deb-result/*.deb result.deb
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.draft_release.outputs.upload_url }}
asset_path: result.deb
asset_name: metranslate-${{ needs.build.outputs.version }}-linux-x86-64.deb
asset_content_type: application/vnd.debian.binary-package
# WINDOWS ZIP
- name: Download windows zip file
uses: actions/download-artifact@v3
with:
name: windows-zip-result
path: windows-zip-result
- name: Copy zip file to root
run: cp windows-zip-result/*.zip result.zip
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.draft_release.outputs.upload_url }}
asset_path: result.zip
asset_name: metranslate-${{ needs.build.outputs.version }}-windows-x86-64.zip
asset_content_type: application/zip