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

Fixing workflow configuration file #504

Open
lordofscripts opened this issue Aug 28, 2024 · 1 comment
Open

Fixing workflow configuration file #504

lordofscripts opened this issue Aug 28, 2024 · 1 comment

Comments

@lordofscripts
Copy link

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?

@DasBen
Copy link

DasBen commented Sep 3, 2024

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.

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