8000 chore: Making the separation between staging and publishing explicit … · CyberSys/firebase-admin-python@a4f2bda · GitHub
  • [go: up one dir, main page]

    Skip to content

    Commit a4f2bda

    Browse files
    authored
    chore: Making the separation between staging and publishing explicit (firebase#407)
    * chore: Running integration tests in release workflow * chore: Making the separation between staging and publishing explicit * Fixing a syntax error * Minor clean up of yml
    1 parent 8143068 commit a4f2bda

    File tree

    2 files changed

    +74
    -15
    lines changed

    2 files changed

    +74
    -15
    lines changed
    Lines changed: 35 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -60,6 +60,41 @@ echo_info "Extracted release version: ${RELEASE_VERSION}"
    6060
    echo "::set-output name=version::v${RELEASE_VERSION}"
    6161

    6262

    63+
    echo_info ""
    64+
    echo_info "--------------------------------------------"
    65+
    echo_info "Check release artifacts"
    66+
    echo_info "--------------------------------------------"
    67+
    echo_info ""
    68+
    69+
    if [[ ! -d dist ]]; then
    70+
    echo_warn "dist directory does not exist."
    71+
    terminate
    72+
    fi
    73+
    74+
    readonly BIN_DIST="dist/firebase_admin-${RELEASE_VERSION}-py3-none-any.whl"
    75+
    if [[ -f "${BIN_DIST}" ]]; then
    76+
    echo_info "Found binary distribution (bdist_wheel): ${BIN_DIST}"
    77+
    else
    78+
    echo_warn "Binary distribution ${BIN_DIST} not found."
    79+
    terminate
    80+
    fi
    81+
    82+
    readonly SRC_DIST="dist/firebase_admin-${RELEASE_VERSION}.tar.gz"
    83+
    if [[ -f "${SRC_DIST}" ]]; then
    84+
    echo_info "Found source distribution (sdist): ${SRC_DIST}"
    85+
    else
    86+
    echo_warn "Source distribution ${SRC_DIST} not found."
    87+
    terminate
    88+
    fi
    89+
    90+
    readonly ARTIFACT_COUNT=`ls dist/ | wc -l`
    91+
    if [[ $ARTIFACT_COUNT -ne 2 ]]; then
    92+
    echo_warn "Unexpected artifacts in the distribution directory."
    93+
    ls -l dist
    94+
    terminate
    95+
    fi
    96+
    97+
    6398
    echo_info ""
    6499
    echo_info "--------------------------------------------"
    65100
    echo_info "Checking previous releases"

    .github/workflows/release.yml

    Lines changed: 39 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -12,7 +12,7 @@
    1212
    # See the License for the specific language governing permissions and
    1313
    # limitations under the License.
    1414

    15-
    name: Release
    15+
    name: Release Candidate
    1616

    1717
    on:
    1818
    # Only run the workflow when a PR is updated or when a developer explicitly requests
    @@ -49,7 +49,7 @@ jobs:
    4949
    run: |
    5050
    python -m pip install --upgrade pip
    5151
    pip install -r requirements.txt
    52-
    pip install wheel
    52+
    pip install setuptools wheel
    5353
    5454
    - name: Run unit tests
    5555
    run: pytest
    @@ -60,8 +60,9 @@ jobs:
    6060
    FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
    6161
    FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
    6262

    63+
    # Build the Python Wheel and the source distribution.
    6364
    - name: Package release artifacts
    64-
    run: python setup.py bdist_wheel bdist_egg
    65+
    run: python setup.py bdist_wheel sdist
    6566

    6667
    # Attach the packaged artifacts to the workflow output. These can be manually
    6768
    # downloaded for later inspection if necessary.
    @@ -71,24 +72,48 @@ jobs:
    7172
    name: dist
    7273
    path: dist
    7374

    75+
    publish_release:
    76+
    needs: stage_release
    77+
    7478
    # Check whether the release should be published. We publish only when the trigger PR is
    7579
    # 1. merged
    7680
    # 2. to the master branch
    7781
    # 3. with the title prefix '[chore] Release '.
    82+
    if: github.event.pull_request.merged &&
    83+
    github.ref == 'master' &&
    84+
    startsWith(github.event.pull_request.title, '[chore] Release ')
    85+
    86+
    runs-on: ubuntu-latest
    87+
    88+
    steps:
    89+
    - name: Checkout source for publish
    90+
    uses: actions/checkout@v2
    91+
    92+
    # Download the artifacts created by the stage_release job.
    93+
    - name: Download release candidates
    94+
    uses: actions/download-artifact@v1
    95+
    with:
    96+
    name: dist
    97+
    98+
    # Python is needed to run Twine and some of the preflight checks.
    99+
    - name: Set up Python
    100+
    uses: actions/setup-python@v1
    101+
    with:
    102+
    python-version: 3.6
    103+
    104+
    - name: Install dependencies
    105+
    run: |
    106+
    python -m pip install --upgrade pip
    107+
    pip install twine
    108+
    78109
    - name: Publish preflight check
    79-
    if: success() && github.event.pull_request.merged &&
    80-
    github.ref == 'master' &&
    81-
    startsWith(github.event.pull_request.title, '[chore] Release ')
    82110
    id: preflight
    83-
    run: |
    84-
    ./.github/scripts/publish_preflight_check.sh
    85-
    echo ::set-env name=FIREBASE_PUBLISH::true
    111+
    run: ./.github/scripts/publish_preflight_check.sh
    86112

    87-
    # Tag the release if not executing in the dryrun mode. We pull this action froma
    88-
    # custom fork of a contributor until https://github.com/actions/create-release/pull/32
    89-
    # is merged. Also note that v1 of this action does not support the "body" parameter.
    113+
    # We pull this action from a custom fork of a contributor until
    114+
    # https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of
    115+
    # this action does not support the "body" parameter.
    90116
    - name: Create release tag
    91-
    if: success() && env.FIREBASE_PUBLISH
    92117
    uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
    93118
    env:
    94119
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    @@ -100,12 +125,11 @@ jobs:
    100125
    prerelease: false
    101126

    102127
    - name: Publish to Pypi
    103-
    if: success() && env.FIREBASE_PUBLISH
    104128
    run: echo Publishing to Pypi
    105129

    106130
    # Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
    107131
    - name: Post to Twitter
    108-
    if: success() && env.FIREBASE_PUBLISH &&
    132+
    if: success() &&
    109133
    contains(github.event.pull_request.labels.*.name, 'release:tweet')
    110134
    run: echo Posting Tweet
    111135
    continue-on-error: true

    0 commit comments

    Comments
     (0)
    0