Skip to content
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

> Task :findSonatypeStagingRepository SKIPPED > Task :releaseSonatypeStagingRepository SKIPPED #305

Open
cesarmax22 opened this issue Jan 24, 2024 · 5 comments

Comments

@cesarmax22
Copy link

cesarmax22 commented Jan 24, 2024

Hi,

I'm trying to achieve the following.
I want to have 2 CI workflows:

  • A: pre-release workflow -> this one publishes to sonatype and closes the repository. ./gradlew clean publishReleasePublicationToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace. This is so we can smoke test properly -> this works FINE. Staging repository is successfully created and closed in sonatype
  • B: release workflow -> once smoke tests is successfull, we can run this workflow that will ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository
    The problem in B, is that I'm getting:
> Task :findSonatypeStagingRepository SKIPPED
> Task :releaseSonatypeStagingRepository SKIPPED

therefore is not being released to maven central.

Since A and B are different workflows, I am doing a checkout of the project on each of them. Just mentioning.

Here is B (release-workflow.yaml)

name: Release

env:
  SONATYPE_USERNAME: <hidden>
  SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
  MAVEN_QA_USER: github
  MAVEN_QA_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
  mavenSigningKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
  mavenSigningKeyRingFileEncoded: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
  mavenSigningKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}

on:
  workflow_dispatch:
    inputs:
      next_version:
        description: 'Next Version (Do NOT include -SNAPSHOT, will be added automatically)'
        required: true

jobs:
  release:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        jdk-version: ["11"]
        ndk-version: ["21.4.7075529"]
    steps:
      - name: Checkout Branch
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          token: ${{ secrets.CD_GITHUB_TOKEN }}

      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@v1

      - name: Gradlew Release to maven central
        run: |
          ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace

      - name: Generate Documentation
        run: ./gradlew dokkaHtml

      - name: Configure git
        run: |
          git config --global user.name 'xxx[bot]'
          git config --global user.email 'xxx@users.noreply.github.com'
          git config --global url."https://${{ secrets.CD_GITHUB_USER }}:${{ secrets.CD_GITHUB_TOKEN }}@github.com".insteadOf "https://github.com"

      - name: Publish gh-pages
        run: |
          mv docs .docs-newly-generated # new docs generated by previous step
          git checkout gh-pages
          git rm -rf docs # old docs on gh-pages branch
          mv .docs-newly-generated docs
          date > docs/version.txt
          echo ${{ github.sha }} >> docs/version.txt
          echo ${{ github.event.release.tag_name }} >> docs/version.txt
          git add -f docs
          git config --global user.name "<hidden>"
          git config --global user.email "xxx@users.noreply.github.com"
          git commit --allow-empty --message 'CI/CD: Automatically generated documentation for ${{ github.event.release.tag_name }}' docs/
          git push --force origin gh-pages

      - name: Record SDK Version History (${{ github.event.inputs.current_version }})
        run: |
          curl -X POST ${{ vars.SDK_VERSION_URL }}/android/version/ -H 'X-CI: ${{ secrets.SDK_VERSION_TOKEN }}' -H 'Content-Type: application/json' -d '{"version": "${{ github.event.inputs.current_version }}"}'

      - name: Set next SDK version
        run: |
          git checkout master
          sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.next_version }}-SNAPSHOT#" gradle.properties
          git add gradle.properties
          git commit -m "CI/CD: set next version: ${{ github.event.inputs.next_version }}"
          git push

      - name: Cleanup Gradle Cache
        # Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
        # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
        # Restoring these files from a GitHub Actions cache might cause problems for future builds.
        run: |
          rm -f ~/.gradle/caches/modules-2/modules-2.lock
          rm -f ~/.gradle/caches/modules-2/gc.properties
@szpak
Copy link
Contributor

szpak commented Jan 24, 2024

Please rerun the skipped tasks with --info to find out the reason of being skipped.

@cesarmax22
Copy link
Author

I think I know the reason. My project had a version ending with -SNAPSHOT.

anyways, I'm not 100% sure, but I think it can be improved. When we run the whole release in 2 steps:
1- publishToSonatype + closeSonatypeRepo
2- findSonatypeRepo + releaseSonatype

I don't think it's necessary in 2 to check if project.version ends with -SNAPSHOT (and therefore skipping tasks); because we're not publishing anything; we're releasing what's already published, right?

not big deal but it may give you a headache to troubleshoot. I had to actually debug the plugin to find this out

regards

@szpak
Copy link
Contributor

szpak commented Jan 25, 2024

Yes, that might be a problem. findSonatypeRepo has been added "recently" and the majority of people use approach where publishTo* is used together with close/rerelease*. However, you can override the default value:

useStaging.convention(project.provider { !project.version.toString().endsWith("-SNAPSHOT") })

just by settings useStaging to true, probably depending on your some custom property passed with -P to force/override executing those tasks in the second run.

@cesarmax22
Copy link
Author

quick question

after running:

1- publishToSonatype + closeSonatypeRepo

in order for the developers to start testing, we need the actual sonatype repositories versions (or names) so to test against that. I am trying to come up with a way that developers do not have to manually log in to nexus so to determine what's the nexus repository so to add it to the test app.

do you have any idea to accomplish that?

we'll be running a pre-release.yaml workflow that will end up publishing and closing nexus repository through your plugin; so I was thinking that workflow might output the nexus repository/ies so the dev can see right straight from github CI what are the repos to be tested

does it make sense? I can't think of anything other than forking your plugin and printing on console?

@szpak
Copy link
Contributor

szpak commented Feb 7, 2024

I think it is quite specific to your workflow and I'm not convinced that adding it to the core plugin would be the best idea.

However, the close task keep the staging repository id in its properties. You could create your own task (even "inline task" in your build.gradle or as a separate plugin to share across your projects) which be orchestrated after the close task and read that value, doing with it whatever you want (e.g. sending a message to your IM). Would it work you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants