Skip to content

fix: workflow

fix: workflow #81

name: Go merge workflow
on:
pull_request:
types: [closed]
branches:
- main
jobs:
prepare_release:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release_action_plan.outputs.releases_created }}
tag_name_result: ${{ steps.modify_output.outputs.tag_name_result }} # Rewritten this line
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 #
- name: Install jq
run: sudo apt-get install jq
- name: Release Please
id: release_action_plan
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: .github/configuration/release-please-config.json
manifest-file: .github/configuration/release-please-manifest.json
include-component-in-tag: true
- name: Set up content output
id: modify_output
if: steps.release_action_plan.outputs.releases_created == 'true'
uses: actions/github-script@v5
with:
script: |
const allOutputs = ${{ steps.release_action_plan.outputs }};
const pathsReleased = JSON.parse('${{ steps.release_action_plan.outputs.paths_released }}');
console.log("pathsReleased",pathsReleased);
let hashMap = {};
let resultArray = [];
for (const [key, value] of Object.entries(allOutputs)) {
// Ensure both key and value are strings
hashMap[String(key)] = String(value);
}
for (const path of pathsReleased) {
const nameKey = `${path}--name`;
if (hashMap[nameKey]) {
const name = hashMap[nameKey].split(':')[0];
resultArray.push(`${path};${hashMap[nameKey]};${name}`);
}
}
core.setOutput("tag_name_result", JSON.stringify(resultArray));
build_and_release:
needs: prepare_release
if: needs.prepare_release.outputs.release_created == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
path: ${{ fromJson(needs.prepare_release.outputs.tag_name_result) }}
exclude:
- goarch: arm64
goos: windows
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: form right entities
id: set_right_names
run: |
IFS=';' read -ra ADDR <<< "${{ matrix.path }}"
echo "::set-output name=path::${ADDR[0]}"
echo "::set-output name=release_tag::${ADDR[1]}"
echo "::set-output name=binary_name::${ADDR[2]}"
- name: Build and Release Go Binary
uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://go.dev/dl/go1.22.0.linux-amd64.tar.gz"
project_path: ${{ steps.set_right_names.outputs.path}}
binary_name: ${{ steps.set_right_names.outputs.binary_name}}
release_tag: ${{ steps.set_right_names.outputs.release_tag}}
overwrite: true