Skip to content

Commit

Permalink
Update release job
Browse files Browse the repository at this point in the history
  • Loading branch information
crow committed Nov 16, 2024
1 parent 301fd81 commit 1fdc314
Showing 1 changed file with 49 additions and 68 deletions.
117 changes: 49 additions & 68 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ on:
type: boolean
default: false
version:
description: 'Version number (e.g., 1.0.0)'
required: true
description: 'Version to use for dry run'
required: false
type: string
default: ''

env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
Expand All @@ -24,86 +26,74 @@ env:
jobs:
ci:
runs-on: macos-14-xlarge

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
flutter-version: ${{env.FLUTTER_VERSION}}
- name: Run CI
run: bash ./scripts/run_ci_tasks.sh

prepare-release:
release-plugin:
runs-on: ubuntu-latest
needs: [ ci ]
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
release_notes: ${{ steps.get_release_notes.outputs.NOTES }}
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get the version
id: get_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
if [[ "${{ inputs.dry_run }}" == "true" && "${{ inputs.version }}" != "" ]]; then
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
VERSION="${{ github.event.inputs.version }}"
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Get the release notes
id: get_release_notes
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "NOTES<<$delimiter"
echo "NOTES<<${delimiter}"
awk "/## Version $VERSION/{flag=1;next}/## Version/{flag=0}flag" CHANGELOG.md
echo "$delimiter"
echo ${delimiter}
} >> $GITHUB_OUTPUT
publish:
needs: [ prepare-release ]
if: ${{ github.event.inputs.dry_run != 'true' }}
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
with:
working-directory: .

publish-check:
needs: [ prepare-release ]
if: ${{ github.event.inputs.dry_run == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get
- name: Publish dry run
run: dart pub publish --dry-run

create-github-release:
runs-on: ubuntu-latest
needs: [ prepare-release, publish ]
if: ${{ github.event.inputs.dry_run != 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
- run: flutter pub get
- name: Publish to pub.dev
if: ${{ !inputs.dry_run }}
uses: dart-lang/setup-dart/.github/workflows/setup-dart@v1
with:
sdk: any
- name: Dry Run Publish to pub.dev
if: ${{ inputs.dry_run }}
uses: dart-lang/setup-dart/.github/workflows/setup-dart@v1
with:
sdk: any
dry-run: true
- name: Github Release
uses: actions/[email protected]
if: ${{ !inputs.dry_run }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.prepare-release.outputs.version }}
release_name: ${{ needs.prepare-release.outputs.version }}
body: ${{ needs.prepare-release.outputs.release_notes }}
name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.get_release_notes.outputs.NOTES }}
draft: false
prerelease: false

- name: Slack Notification
uses: homoluctus/slatify@master
if: failure()
Expand All @@ -114,50 +104,41 @@ jobs:

release-docs:
runs-on: macos-14-xlarge
needs: [ publish ]
if: ${{ github.event.inputs.dry_run != 'true' }}
needs: [ ci, release-plugin ]
if: ${{ !inputs.dry_run }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get the version
id: get_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
if [[ "${{ inputs.dry_run }}" == "true" && "${{ inputs.version }}" != "" ]]; then
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
VERSION="${{ github.event.inputs.version }}"
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}

- name: Flutter action
uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- name: Setup GCP Auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: Build & Package docs
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
flutter pub get
bash ./scripts/docs.sh -gp $VERSION doc/api
- name: Upload docs
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
gsutil cp doc/$VERSION.tar.gz gs://ua-web-ci-prod-docs-transfer/libraries/flutter/$VERSION.tar.gz
- name: Slack Notification
uses: homoluctus/slatify@master
with:
Expand Down

0 comments on commit 1fdc314

Please sign in to comment.