CI: Add release workflow
parent
0069d6c2a2
commit
53d25548dc
@ -0,0 +1,179 @@
|
||||
name: Release Workflow
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
concurrency:
|
||||
group: release_workflow
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
FLUTTER_VERSION: ${{ secrets.FLUTTER_VERSION }}
|
||||
JAVA_VERSION: ${{ secrets.JAVA_VERSION }}
|
||||
|
||||
jobs:
|
||||
build_web:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install nodejs -y
|
||||
- run: flutter pub get
|
||||
- name: Prepare web
|
||||
run: ./scripts/prepare-web.sh
|
||||
- name: Build Release Web
|
||||
run: flutter build web --release --verbose --source-maps
|
||||
- name: Create archive
|
||||
run: tar -czf fluffychat-web-${{ github.ref }}.tar.gz build/web/
|
||||
|
||||
|
||||
build_apk:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
- name: Apply Google Services Patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
- run: flutter pub get
|
||||
- name: Prepare Android Release Build
|
||||
env:
|
||||
FDROID_KEY: ${{ secrets.FDROID_KEY }}
|
||||
FDROID_KEY_PASS: ${{ secrets.FDROID_KEY_PASS }}
|
||||
PLAYSTORE_DEPLOY_KEY: ${{ secrets.PLAYSTORE_DEPLOY_KEY }}
|
||||
run: ./scripts/prepare-android-release.sh
|
||||
- run: flutter build apk --release
|
||||
|
||||
build_linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install curl clang cmake ninja-build pkg-config libgtk-3-dev libblkid-dev liblzma-dev libjsoncpp-dev cmake-data libsecret-1-dev libsecret-1-0 librhash0 -y
|
||||
- run: flutter pub get
|
||||
- run: flutter build linux --release
|
||||
- name: Create archive
|
||||
run: tar -czf fluffychat-linux-${{ matrix.architecture }}-${{ github.ref }}.tar.gz build/linux/${{ matrix.architecture }}/release/bundle/
|
||||
|
||||
deploy_playstore:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.7
|
||||
- name: Install Fastlane
|
||||
run: gem install fastlane -NV
|
||||
- name: Apply Google Services Patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
- run: flutter pub get
|
||||
- name: Prepare Android Release Build
|
||||
env:
|
||||
FDROID_KEY: ${{ secrets.FDROID_KEY }}
|
||||
FDROID_KEY_PASS: ${{ secrets.FDROID_KEY_PASS }}
|
||||
PLAYSTORE_DEPLOY_KEY: ${{ secrets.PLAYSTORE_DEPLOY_KEY }}
|
||||
run: ./scripts/prepare-android-release.sh
|
||||
- name: Build Android Release
|
||||
run: flutter build appbundle --target-platform android-arm,android-arm64,android-x64
|
||||
- name: Get Tag Name
|
||||
id: tag_name
|
||||
run: echo "::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})"
|
||||
- name: Deploy Android Release
|
||||
run: |
|
||||
mkdir -p build/android
|
||||
cp build/app/outputs/bundle/release/app-release.aab build/android/
|
||||
cd android
|
||||
bundle install
|
||||
bundle update fastlane
|
||||
RELEASE_TYPE=$(echo "${{ github.ref }}" | awk -F"/" '{print $3}')
|
||||
if [ "$RELEASE_TYPE" = "rc" ]; then
|
||||
bundle exec fastlane deploy_candidate
|
||||
else
|
||||
bundle exec fastlane deploy_release
|
||||
fi
|
||||
cd ..
|
||||
|
||||
release:
|
||||
needs: [build_linux, build_web, build_apk]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload Linux (x64) Build
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Linux Build
|
||||
path: fluffychat-linux-x64-${{ github.ref }}.tar.gz
|
||||
- name: Upload Linux (arm64) Build
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Linux Build
|
||||
path: fluffychat-linux-arm64-${{ github.ref }}.tar.gz
|
||||
- name: Upload Web Build
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Web Build
|
||||
path: fluffychat-web-${{ github.ref }}.tar.gz
|
||||
- name: Upload APK Build
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: APK Build
|
||||
path: build/app/outputs/apk/release/app-release.apk
|
||||
- name: Get Release URL
|
||||
id: get_release_url
|
||||
run: echo "::set-output name=url::$(echo ${{ github.event.repository.html_url }}/releases/tag/${{ github.ref }})"
|
||||
- name: Add Download Links to Release Description
|
||||
run: |
|
||||
echo "Download the built artifacts from the following links:" >> release_description.txt
|
||||
echo "- Linux(x64): [Download](${{ needs.build_linux.outputs.artifact_url }})" >> release_description.txt
|
||||
echo "- Linux(arm64): [Download](${{ needs.build_linux.outputs.artifact_url }})" >> release_description.txt
|
||||
echo "- Web: [Download](${{ needs.build_web.outputs.artifact_url }})" >> release_description.txt
|
||||
echo "- APK: [Download](${{ needs.build_apk.outputs.artifact_url }})" >> release_description.txt
|
||||
cat release_description.txt | gh release upload ${{ github.ref }} -
|
||||
- name: Publish Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAGES_DEPLOY_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: release_description.txt
|
||||
asset_name: release_description.txt
|
||||
asset_content_type: text/plain
|
@ -1,37 +0,0 @@
|
||||
#!/bin/bash -ve
|
||||
|
||||
# source: https://about.gitlab.com/blog/2017/09/05/how-to-automatically-create-a-new-mr-on-gitlab-with-gitlab-ci/
|
||||
|
||||
# Extract the host where the server is running, and add the URL to the APIs
|
||||
[[ $HOST =~ ^https?://[^/]+ ]] && HOST="${BASH_REMATCH[0]}/api/v4/projects/"
|
||||
|
||||
# Look which is the default branch
|
||||
TARGET_BRANCH=`curl --silent "${HOST}${CI_PROJECT_ID}" --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" | python3 -c "import sys, json; print(json.load(sys.stdin)['default_branch'])"`;
|
||||
|
||||
# The description of our new MR, we want to remove the branch after the MR has
|
||||
# been closed
|
||||
BODY="{
|
||||
\"id\": ${CI_PROJECT_ID},
|
||||
\"source_branch\": \"${UPDATE_BRANCH}\",
|
||||
\"target_branch\": \"${TARGET_BRANCH}\",
|
||||
\"remove_source_branch\": true,
|
||||
\"title\": \"chore: automated dependency update\"
|
||||
}";
|
||||
|
||||
# Require a list of all the merge request and take a look if there is already
|
||||
# one with the same source branch
|
||||
LISTMR=`curl --silent "${HOST}${CI_PROJECT_ID}/merge_requests?state=opened" --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}"`;
|
||||
COUNTBRANCHES=`echo ${LISTMR} | grep -o "\"source_branch\":\"${UPDATE_BRANCH}\"" | wc -l`;
|
||||
|
||||
# No MR found, let's create a new one
|
||||
if [ ${COUNTBRANCHES} -eq "0" ]; then
|
||||
curl -X POST "${HOST}${CI_PROJECT_ID}/merge_requests" \
|
||||
--header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data "${BODY}";
|
||||
|
||||
echo "Opened a new dependency update MR."
|
||||
exit;
|
||||
fi
|
||||
|
||||
echo "No new merge request opened.";
|
@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
flutter pub get
|
||||
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
|
||||
mkdir -p build/android
|
||||
cp build/app/outputs/bundle/release/app-release.aab build/android/
|
||||
cd android
|
||||
bundle install
|
||||
bundle update fastlane
|
||||
bundle exec fastlane deploy_internal_test
|
||||
cd ..
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh -ve
|
||||
RELEASE_TYPE=$(echo $CI_COMMIT_TAG | grep -oE "[a-z]+")
|
||||
cd android
|
||||
if [ "$RELEASE_TYPE" = "rc" ]; then
|
||||
bundle exec fastlane deploy_candidate
|
||||
else
|
||||
bundle exec fastlane deploy_release
|
||||
fi
|
||||
cd ..
|
Loading…
Reference in New Issue