Release #21
This file contains hidden or 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: Release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
build: | |
name: Build for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
include: | |
- os: macos-latest | |
artifact_prefix: macos | |
target: x86_64-apple-darwin | |
- os: ubuntu-latest | |
artifact_prefix: linux | |
target: x86_64-unknown-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: wasabeef/[email protected] | |
id: asdf | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ steps.asdf.outputs.flutter }} | |
channel: stable | |
cache: true | |
- name: Set environment | |
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH | |
- name: Get dependencies | |
run: | | |
dart pub global activate melos | |
melos bootstrap | |
- name: Running build | |
run: | | |
cd packages/command/ | |
mkdir -p bin/${{ matrix.target }} | |
dart compile exe bin/flutter_gen_command.dart -o bin/${{ matrix.target }}/fluttergen | |
- name: Packaging final binary | |
shell: bash | |
run: | | |
cd packages/command/bin/${{ matrix.target }} | |
tar czvf fluttergen-${{ matrix.artifact_prefix }}.tar.gz fluttergen | |
shasum -a 256 fluttergen-${{ matrix.artifact_prefix }}.tar.gz > fluttergen-${{ matrix.artifact_prefix }}.sha256 | |
- name: Releasing assets | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
packages/command/bin/${{ matrix.target }}/fluttergen-${{ matrix.artifact_prefix }}.tar.gz | |
packages/command/bin/${{ matrix.target }}/fluttergen-${{ matrix.artifact_prefix }}.sha256 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sha256-${{ strategy.job-index }} | |
path: packages/command/bin/${{ matrix.target }}/fluttergen-${{ matrix.artifact_prefix }}.sha256 | |
update: | |
name: Update Homebrew tap | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/[email protected] | |
with: | |
pattern: sha256-* | |
merge-multiple: true | |
# GitHub Apps | |
- name: Generate github apps token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.FLUTTEGEN_APP_ID }} | |
private-key: ${{ secrets.FLUTTEGEN_APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- id: version | |
run: echo "::set-output name=version::${GITHUB_REF##*/}" | |
- id: checksum | |
shell: bash | |
run: | | |
echo ::set-output name=sha256_linux::$(cat fluttergen-linux.sha256 | awk '{ print $1 }') | |
echo ::set-output name=sha256_macos::$(cat fluttergen-macos.sha256 | awk '{ print $1 }') | |
- uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
repository: FlutterGen/homebrew-tap | |
event-type: update-tap | |
client-payload: '{ "sha256_linux": "${{ steps.checksum.outputs.sha256_linux }}", "sha256_macos": "${{ steps.checksum.outputs.sha256_macos }}", "version": "${{ steps.version.outputs.version }}" }' |