softprops / action-gh-release

📦 :octocat: GitHub Action for creating GitHub Releases
MIT License
4.13k stars 450 forks source link

Create Release from different branch #344

Closed tomkeuper closed 1 year ago

tomkeuper commented 1 year ago

I want to create a release based of the non master branch, in my case its called 'production' I have an artifact that it succesfully uploads to the release but the source code that it adds and the release notes dont match as they are based of master which is not yet up to date with production.

Because when a release should be made it goes from Development > production > master. This way I make sure that master always contains the code thats running in production.

It might be already possible but then I just cant figure out how to do this

tomkeuper commented 1 year ago

I've noticed this can by done by setting: target_commitish:

Imo this does not reflect the wiki because this is not a commit but it works

ericwq commented 8 months ago

for me, it failed even if target_commitish is used. in the following code, needs.change_build_info.outputs.commit_hash is commit id, it's value like 5a804af0d5661f021df4c98793a540010654d91d.

@tomkeuper how to use target_commitish correctly?

  release:
    needs: change_build_info
    runs-on: ubuntu-latest
    steps:
      - name: checkout repo again
        uses: actions/checkout@master
        with:
          ref: ${{ needs.change_build_info.outputs.commit_hash }}

      - name: print value
        id: print
        run: |
          echo "github.ref=${{ github.ref }}"
          echo "github.sha=${{ github.sha }}"
          echo "commit_hash=${{ needs.change_build_info.outputs.commit_hash }}"
          head -n 21 build/APKBUILD

      - name: publish release assets
        uses: softprops/action-gh-release@master
        with:
          generate_release_notes: true
          target_commitish: ${{ needs.change_build_info.outputs.commit_hash }}
tomkeuper commented 8 months ago

for me, it failed even if target_commitish is used. in the following code, needs.change_build_info.outputs.commit_hash is commit id, it's value like 5a804af0d5661f021df4c98793a540010654d91d.

@tomkeuper how to use target_commitish correctly?

  release:
    needs: change_build_info
    runs-on: ubuntu-latest
    steps:
      - name: checkout repo again
        uses: actions/checkout@master
        with:
          ref: ${{ needs.change_build_info.outputs.commit_hash }}

      - name: print value
        id: print
        run: |
          echo "github.ref=${{ github.ref }}"
          echo "github.sha=${{ github.sha }}"
          echo "commit_hash=${{ needs.change_build_info.outputs.commit_hash }}"
          head -n 21 build/APKBUILD

      - name: publish release assets
        uses: softprops/action-gh-release@master
        with:
          generate_release_notes: true
          target_commitish: ${{ needs.change_build_info.outputs.commit_hash }}

You dont put the commit hash in that field, you should use the branch name. Take a look at my task: https://github.com/tomkeuper/BedWars2023/blob/8f49381130e7243f70dfee353ad5e970399d3aa6/.github/workflows/deploy.yml#L52