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

PRE_RELEASE/UNRELEASED always creates a new DRAFT release #122

Closed
tajobe opened this issue Jan 10, 2024 · 5 comments
Closed

PRE_RELEASE/UNRELEASED always creates a new DRAFT release #122

tajobe opened this issue Jan 10, 2024 · 5 comments
Assignees
Labels
bug Looks like an issue v5 Release v5.x.x

Comments

@tajobe
Copy link
Contributor

tajobe commented Jan 10, 2024

Description

When attempting to always release a latest snapshot for each push to main, DRAFT releases are continuously created instead of a single prerelease being updated/replaced.

Tag

5.0.2 (using docker v5)

Workflow

This is the workflow I use to create a pre-release for main branch updates or a "true" release on semantic version tag.

name: Publish
on:
  push:
    branches: [ 'main' ]
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

jobs:
  build:
    uses: ./.github/workflows/build.yml
    with:
      push: true
    secrets: inherit
  publish:
    needs: build
    name: Publish Release
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Download dist
        uses: actions/download-artifact@v3
        id: download
        with:
          name: dist
          path: dist
      - name: Release
        uses: docker://antonyurchenko/git-release:v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          RELEASE_NAME: ${{ needs.build.outputs.version }}
          PRE_RELEASE: ${{ github.ref_type == 'branch' }}
          UNRELEASED: ${{ github.ref_type == 'branch' && 'update' || '' }}
          UNRELEASED_TAG: latest-snapshot
          DRAFT_RELEASE: false
          ALLOW_EMPTY_CHANGELOG: ${{ github.ref_type == 'branch' && 'true' || 'false' }}
        with:
          args: |
            dist/libs/*-all.jar
            dist/distributions/*-shadow-*.tar.gz

Changelog

Attach a full changelog

I can't do that, but I don't think it's relevant here, and the releases are appropriately getting the changelog entries.

Log

Run docker://antonyurchenko/git-release:v5
  with:
    args: dist/libs/*-all.jar
  dist/distributions/*-shadow-*.tar.gz
  
  env:
    GITHUB_TOKEN: ***
    RELEASE_NAME: 0.7.1-SNAPSHOT
    PRE_RELEASE: true
    UNRELEASED: update
    UNRELEASED_TAG: latest-snapshot
    DRAFT_RELEASE: false
    ALLOW_EMPTY_CHANGELOG: true
/usr/bin/docker run --name antonyurchenkogitreleasev5_8749b8 --label 86c800 --workdir /github/workspace --rm -e "GITHUB_TOKEN" -e "RELEASE_NAME" -e "PRE_RELEASE" -e "UNRELEASED" -e "UNRELEASED_TAG" -e "DRAFT_RELEASE" -e "ALLOW_EMPTY_CHANGELOG" -e "INPUT_ARGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/<*snip*>":"/github/workspace" antonyurchenko/git-release:v5 dist/libs/*-all.jar
dist/distributions/*-shadow-*.tar.gz
DEBUG git-release v5.0.2                           
WARNING deleting precedent release ❗                 
WARNING precedent release not found                  
INFO creating 0.7.1-SNAPSHOT release              
INFO release created successfully 🎉               
INFO uploading asset                               asset=<*snip*>-0.7.1-SNAPSHOT.tar.gz
INFO uploading asset                               asset=<*snip*>-0.7.1-SNAPSHOT-all.jar
INFO assets uploaded successfully 🎉              

Screenshots

If applicable, add screenshots to help explain your problem.

Unfortunately I just cleaned up all the draft releases (a couple dozen of them), but I will try to add a screenshot when more merges to main happen. Ultimately it's creating draft releases when I don't think it should, and thus cannot find the previous prerelease to update for latest.

@anton-yurchenko
Copy link
Owner

Hello @tajobe,
As per the log, it seems it cannot find an existing Release created upon the latest-snapshot tag.
Although it successfully deleted the latest-snapshot tag.

Please add a screenshot of the current release, then execute the CI flow and provide two more screenshots: the new release created and the previous release (which became a draft at this stage). In addition to that, we will also need an execution log.

@tajobe
Copy link
Contributor Author

tajobe commented Jan 14, 2024

@anton-yurchenko Unfortunately I cannot share much about the project, but the reason it doesn't find the previous release is because it was created as a DRAFT, even though DRAFT is false. If I manually publish the previous DRAFT the next run finds it rather than creating a new one, but then publishes as a DRAFT. The creation of new releases seems a symptom of it publishing as a DRAFT.

I will try to reproduce on an open/public repository.

@tajobe
Copy link
Contributor Author

tajobe commented Jan 14, 2024

@anton-yurchenko I've reproduced this here:

https://github.com/tajobe/git-release-issue-122/releases
https://github.com/tajobe/git-release-issue-122/actions

...The first workflow run with a clean slate (no tag, no releases) worked well, creating a Pre-Release release as desired, but the second run converted the existing release to a Draft. The run after that created a second Draft. None of these have been touched manually, and were just created with the git-release action, though I did have a few prior runs that I cleaned up to have a fresh slate for reproduction (deleted the tag, all releases, and actions runs).

image

  • Initial, successful release workflow: logs_5.zip
  • Second workflow/release...updated, switched to a draft: logs_6.zip
  • Third workflow/release - created a second draft release logs_7.zip

@anton-yurchenko
Copy link
Owner

Understood, thank you.
I will investigate this and get back to you.

@anton-yurchenko anton-yurchenko added bug Looks like an issue v5 Release v5.x.x labels Jan 17, 2024
@anton-yurchenko
Copy link
Owner

I was able to identify a root cause for this issue; it is a race condition. The API requires some time to clean up the previous release, so adding a slight delay between the Delete and Create commands resolves this issue.

This fix is shipped along with other upgrades in the v6.0.0

Thank you for raising this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Looks like an issue v5 Release v5.x.x
Projects
None yet
Development

No branches or pull requests

2 participants