Publish sirenapp_flutter_inbox in pub.dev #9
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: Publish sirenapp_flutter_inbox in pub.dev | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ReleaseType: | |
| description: 'Release Type' | |
| required: true | |
| default: 'Patch' | |
| type: choice | |
| options: | |
| - "Major" | |
| - "Minor" | |
| - "Patch" | |
| jobs: | |
| publish: | |
| permissions: | |
| id-token: write # Required for authentication using OIDC | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get branch names. | |
| id: branch-names | |
| uses: tj-actions/branch-names@v8 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Git | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| export BRANCH=${{ steps.branch-names.outputs.current_branch }} | |
| echo "branch: $BRANCH" | |
| if [[ "$BRANCH" != "master" ]]; then | |
| echo "Tagging cannot be done on a branch other than master" | |
| echo $BRANCH | |
| exit 1 | |
| fi | |
| export VERSION=$(cat pubspec.yaml | grep "version:" | awk '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//') | |
| echo $VERSION | |
| export UPDATE_CHOICE=${{ inputs.ReleaseType }} | |
| export MAJOR=$(echo $VERSION | cut -d. -f1) | |
| export MINOR=$(echo $VERSION | cut -d. -f2) | |
| export PATCH=$(echo $VERSION | cut -d"+" -f1 | cut -d"." -f3) | |
| if [[ "$UPDATE_CHOICE" == "Major" ]]; then export NEW_TAG=$((MAJOR + 1)).0.0; fi | |
| if [[ "$UPDATE_CHOICE" == "Minor" ]]; then export NEW_TAG=$MAJOR.$((MINOR + 1)).0; fi | |
| if [[ "$UPDATE_CHOICE" == "Patch" ]]; then export NEW_TAG=$MAJOR.$MINOR.$((PATCH + 1)); fi | |
| echo NEW_TAG $NEW_TAG | |
| echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
| sed -i "s/version: $VERSION/version: $NEW_TAG/g" pubspec.yaml | |
| - uses: actions/setup-java@v1 | |
| with: | |
| java-version: '12.x' | |
| - uses: subosito/flutter-action@v1 | |
| with: | |
| channel: 'stable' | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Analyze project source | |
| run: flutter analyze lib/ | |
| - name: Run tests | |
| run: flutter test lib/ | |
| - name: Setup Pub Credentials | |
| shell: bash | |
| env: | |
| INPUT_ACCESS_TOKEN: ${{ secrets.INPUT_ACCESS_TOKEN }} | |
| INPUT_REFRESH_TOKEN: ${{ secrets.INPUT_REFRESH_TOKEN }} | |
| run: | | |
| sh ./pub_login.sh | |
| - name: Check Publish Warnings | |
| run: flutter pub publish --dry-run | |
| - name: Publish Package | |
| run: flutter pub publish -f | |
| - name: Commit pubspec.yaml | |
| if: success() | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEW_TAG: ${{ env.NEW_TAG }} | |
| run: | | |
| git add pubspec.yaml | |
| git commit -m "Version bumped to $NEW_TAG" | |
| git push origin $BRANCH | |
| - name: Create New Tag | |
| if: success() | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEW_TAG: ${{ env.NEW_TAG }} | |
| run: | | |
| git tag v${{ env.NEW_TAG }} | |
| git push origin v${{ env.NEW_TAG }} | |
| - name: Create GitHub release | |
| if: success() | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEW_TAG: ${{ env.NEW_TAG }} | |
| with: | |
| tag_name: v${{ env.NEW_TAG }} | |
| release_name: Release v${{ env.NEW_TAG }} | |
| draft: false | |
| prerelease: false | |