action-gh-release icon indicating copy to clipboard operation
action-gh-release copied to clipboard

Fixing workflow configuration file

Open lordofscripts opened this issue 1 year ago • 1 comments

I am new to workflows and have a cross-build workflow in my project which uses this action-gh-release. For now I have it triggered on watch so that I don't have to make fake releases just to test the workflow.

# workflow name
name: CrossBuild

# on events
on:
  watch:
    types:
      - started

# This crossbuild from Kuechlin/gotris
#on:
#  push:
#    # Sequence of patterns matched against refs/tags
#    tags:
#      - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

permissions:
  contents: write

defaults:
  run:
    shell: bash


# jobs
jobs:
  # Build
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        goosarch:
          - 'linux/386'
#          - 'linux/amd64'
          - 'windows/386'
#          - 'windows/amd64'
          - 'linux/arm'
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: '1.22.1'
      - name: Get OS and arch info
        run: |
          GOOSARCH=${{matrix.goosarch}}
          GOOS=${GOOSARCH%/*}
          GOARCH=${GOOSARCH#*/}
          BINARY_NAME=${{github.repository}}-$GOOS-$GOARCH
          echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
          echo "GOOS=$GOOS" >> $GITHUB_ENV
          echo "GOARCH=$GOARCH" >> $GITHUB_ENV
      - name: Build
        run: |
          go build -o "$BINARY_NAME" -v
      - name: Release Notes
        run:
          git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n  * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
      - name: Release with Notes
        uses: softprops/action-gh-release@v2
        with:
          body_path: ".github/RELEASE-TEMPLATE.md"
          draft: true
          files: ${{env.BINARY_NAME}}

As you can see in the last part I am using action-gh-release but I wonder what should I do with that body_path? I don't see that file is created, so is it actually an input file? and if so, which keywords are expected by action-gh-release within that file to create the release?

Secondary question (sorry!) is there a simple way to add the release tag to the BINARY_NAME?

lordofscripts avatar Aug 28 '24 15:08 lordofscripts

The body_path should be referencing a file you have created. We use it with placeholders like <!-- PLACEHOLDER --> which get's replaced in the WF with sed commands. If you don't want a file, but instead pass the body itself, then you can use body instead of body_path.

I do not develop in go, but in java I would rename the file and append the version. Or leave it as without version and use the same name for an auto deployment further down the pipeline.

DasBen avatar Sep 03 '24 06:09 DasBen