Skip to content

How to create prereleases for feature branches? #192

@wood-jp

Description

@wood-jp

I'm using the Github Action, but willing to try other things. Here's what I have now (note that develop is the default branch):

name: Release
on:
  workflow_dispatch:
  push:
    branches:
      - develop
      - feature/*

permissions:
  contents: read # for checkout

env:
  BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
  release:
    runs-on: ubuntu-latest
    name: Release
    if: ${{ github.ref == 'refs/heads/develop' }} # full release only on develop branch
    permissions:
      contents: write # to be able to publish a GitHub release
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.24
      - name: Execute Release
        uses: go-semantic-release/action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          force-bump-patch-version: true
          changelog-generator-opt: "emojis=true"
          prerelease: false

  pre-release:
    runs-on: ubuntu-latest
    name: Pre-Release
    if: ${{ github.ref != 'refs/heads/develop' }} # full release only on develop branch
    permissions:
      contents: write # to be able to publish a GitHub release
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.24
      - name: Execute Release
        uses: go-semantic-release/action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          force-bump-patch-version: true
          changelog-generator-opt: "emojis=true"
          prerelease: true # full release only on develop branch

And what I'm trying to accomplish is:

  1. A proper release should happen when a merge is done to the develop branch. This works as expected.
  2. A pre-release should happen when a merge is done to any branch named feature/*. I want the tag to be vX.X.X-yyy.Z where:
  • vX.X.X is the most recent full release tag on which the feature branch is based.
  • yyy is an alphanumeric string that I can pass (I would base this on the branch name).
  • Z is an auto-incrementing integer for each such prerelease.

I have played around with the custom-arguments passing --maintained-version of various kinds, but I am not having much success. Reading other issues has not been helpful either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions