Skip to content

chore: upgrade workflows (#2371) #2383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/gen_code/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Gen code
description: 'Generate code for the given public headers'

inputs:
code_gen_public_headers:
description: 'The public headers to generate, e.g. rtc_4.5.0, leave empty will use the same as the target branch'
required: false
default: ''

flutter_channel:
description: 'Target Flutter channel, e.g. stable(default), beta, dev, master (or main), or any other channel name'
required: false
default: 'stable'

flutter_version:
description: 'Target Flutter version, e.g. 3.24.5, 3.24.x, commit hash, or leave empty to use the latest release version of specified channel by flutter_version(default)'
required: false
# we should use the latest stable version for build and gen code, but the 3.19.6 is the latest version which will gen compatible code for our flutter project,
# so we fixed use the 3.19.6 version here for now
default: '3.19.6'

working_directory:
description: 'The working directory of the action'
required: false
default: './'

runs:
using: composite
steps:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ inputs.flutter_channel }}
flutter-version: ${{ inputs.flutter_version }}
cache: true

- name: Gen
uses: AgoraIO-Extensions/actions/.github/actions/generate@main
with:
generate-code: true
generate-comment: false
working-directory: ${{ inputs.working_directory }}
generate-code-command: |
corepack enable && bash scripts/code_gen.sh ${{ inputs.code_gen_public_headers }}
generate-comment-command: ""
github-token: ""

69 changes: 69 additions & 0 deletions .github/actions/prepare_branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Prepare branch
description: 'Prepare a branch for the given pub version'

inputs:
target_branch:
description: 'The target branch to prepare the branch for'
required: true

pub_version:
description: 'The pub version to prepare the branch for'
required: true

branch_group:
description: 'The group of the branch name, e.g. special or dev, default is special'
required: false
default: 'special'

working_directory:
description: 'The working directory of the action'
required: false
default: './'

outputs:
final_target_branch:
description: 'The final target branch'
value: ${{ steps.prepare.outputs.final_target_branch }}

runs:
using: composite
steps:
- name: Prepare branch
id: prepare
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
# Fetch all remote refs
git fetch --all

# Function to check if branch exists remotely
check_remote_branch() {
git ls-remote --heads origin "refs/heads/$1" | grep -q "refs/heads/$1$"
return $?
}

# Check if target_branch exists as a remote branch
check_remote_branch "${{ inputs.target_branch }}"
if [ $? -ne 0 ]; then
echo "Target branch does not exist as a remote branch, treating as a commit/tag reference"

# get pub_version from pubspec.yaml if inputs.pub_version is empty
pub_version=${{ inputs.pub_version }}
if [ -z "${pub_version}" ]; then
pub_version=$(grep 'version: ' pubspec.yaml | sed -e 's,.*: \(.*\),\1,')
fi

final_target_branch=${{ inputs.branch_group }}/${pub_version}

# create a new branch named "${{ inputs.branch_group }}/${pub_version}" from the reference
git checkout -B ${final_target_branch}

# push the new branch to the remote repository, set the result always as success even if the push failed
git push -u origin HEAD:${final_target_branch} || true
else
echo "Target branch exists as a remote branch"
final_target_branch="${{ inputs.target_branch }}"

fi

echo "final_target_branch=${final_target_branch}" >> $GITHUB_OUTPUT
13 changes: 13 additions & 0 deletions .github/actions/pub/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM dart:latest

RUN pwd

# RUN echo "Files in current directory:" && ls -la .

COPY . /

RUN chmod +x /entrypoint.sh

# RUN echo "Files after COPY:" && ls -la /

ENTRYPOINT ["/entrypoint.sh"]
69 changes: 69 additions & 0 deletions .github/actions/pub/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# https://github.com/k-paxian/dart-package-publisher
name: 'Dart and Flutter Package Publisher'
description: 'Continuously Test & Publish Dart and Flutter Package To Pub.dev When Version Changed'
author: 'k-paxian'
branding:
color: 'blue'
icon: 'package'
inputs:
accessToken:
description: '(Required) Token from ~/.pub-cache/credentials.json. Use secrets.OAUTH_ACCESS_TOKEN'
required: true
refreshToken:
description: '(Required) Token from ~/.pub-cache/credentials.json. Use secrets.OAUTH_REFRESH_TOKEN'
required: true
credentialJson:
description: '(Optional) Overrides accessToken and refreshToken. Whole content of ~/.pub-cache/credentials.json. Use secrets.CREDENTIAL_JSON'
required: false
relativePath:
description: '(Optional) Path to your package root in your repository'
required: false
default: ''
dryRunOnly:
description: '(Optional) Perform dry run only, no real publishing'
required: false
default: false
testRunOnly:
description: '(Optional) Perform unit tests run only, no real publishing'
required: false
default: false
skipTests:
description: '(Optional) Skip unit tests run'
required: false
default: false
suppressBuildRunner:
description: '(Optional) Suppress using `build_runner` for unit tests run'
required: false
default: false
format:
description: '(Optional) Format code of project to get better score in pub.dev'
required: false
default: false
force:
description: '(Optional) Force publishing even if pub tool throws warnings, hints, etc'
required: false
default: false
flutter:
description: '(Optional) Flutter package type'
required: false
default: false
flutterBranch:
description: '(Optional) Flutter branch to use, stable, master, main, dev, etc.'
required: false
default: 'stable'
outputs:
success:
description: 'Result, "true" if actual publishing happened, "false" otherwise'
package:
description: 'Package name from pubspec'
localVersion:
description: 'Package local version from pubspec'
remoteVersion:
description: 'Package remote version from pub.dev'
dartVersion:
description: 'Dart SDK version which is being used to run tests & publish'
flutterVersion:
description: 'Flutter SDK version which is being used to run tests & publish'
runs:
using: 'docker'
image: 'Dockerfile'
Loading
Loading