From 0ceeaa969e1973c0b06a979c583d9deca26953aa Mon Sep 17 00:00:00 2001 From: Felipe Rios Date: Thu, 8 Feb 2024 22:56:26 -0500 Subject: [PATCH] feat(binary): added the binary release feature for GoLang pipelines Signed-off-by: Felipe Rios --- .github/workflows/go-binary.yaml | 4 ++- CHANGELOG.md | 1 + .../stages/40-delivery/binary/action.yaml | 33 ++++++++++++++++++- .../stages/40-delivery/release/action.yaml | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go-binary.yaml b/.github/workflows/go-binary.yaml index b480fa2a..4ad28e43 100644 --- a/.github/workflows/go-binary.yaml +++ b/.github/workflows/go-binary.yaml @@ -18,6 +18,8 @@ jobs: name: 'delivery > binary' runs-on: 'ubuntu-latest' steps: - - uses: 'rios0rios0/pipelines/github/global/stages/40-delivery/deb-releaser@main' + - uses: 'rios0rios0/pipelines/github/global/stages/40-delivery/binary@main' + with: + binary_name: '${{ env.BINARY_NAME }}' needs: [ 'delivery-release' ] if: "(github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/')" diff --git a/CHANGELOG.md b/CHANGELOG.md index b13c633e..5ca8ab81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Exceptions are acceptable depending on the circumstances (critical bug fixes tha - added a new step to replace the environment variables contained inside the `yaml` file - added a script into the Golang `delivery` to get the new `siteName` variable - added the code check step for GoLang inside the GitHub Actions provider - [#19](https://github.com/rios0rios0/pipelines/issues/19) +- added the binary release feature for GoLang pipelines ### Changed diff --git a/github/global/stages/40-delivery/binary/action.yaml b/github/global/stages/40-delivery/binary/action.yaml index fb8bb334..b2d9ac7d 100644 --- a/github/global/stages/40-delivery/binary/action.yaml +++ b/github/global/stages/40-delivery/binary/action.yaml @@ -1,7 +1,38 @@ on: workflow_call: +inputs: + binary_name: + description: 'Binary name to be used as default source' + required: true + runs: using: 'composite' + env: + PACKAGE_NAME: '${{ inputs.binary_name }}-${{ github.ref[10:] }}' + DEBIAN_FRONTEND: 'noninteractive' steps: - # TODO: it should be finished with: "https://github.com/rios0rios0/autobump/blob/main/.github/workflows/release.yml#L68" + - run: | + make build + strip -s bin/${{ inputs.binary_name }} + shell: 'bash' + - run: | + cd bin + zip -9 ${{ env.PACKAGE_NAME }}.zip ${{ inputs.binary_name }} + shell: 'bash' + - uses: 'actions/upload-artifact@v2' + with: + name: '${{ inputs.binary_name }}' + path: 'bin/${{ env.PACKAGE_NAME }}.zip' + - uses: 'actions/download-artifact@v2' + with: + name: '${{ inputs.binary_name }}' + - uses: 'actions/upload-release-asset@v1' + # TODO: is this really necessary? + #env: + # GITHUB_TOKEN: '${{ github.token }}' + with: + upload_url: '${{ steps.create_release.outputs.upload_url }}' + asset_path: '${{ env.PACKAGE_NAME }}.zip' + asset_name: '${{ env.PACKAGE_NAME }}.zip' + asset_content_type: 'application/zip' diff --git a/github/global/stages/40-delivery/release/action.yaml b/github/global/stages/40-delivery/release/action.yaml index 73e10a25..b2a78198 100644 --- a/github/global/stages/40-delivery/release/action.yaml +++ b/github/global/stages/40-delivery/release/action.yaml @@ -4,7 +4,7 @@ on: runs: using: 'composite' outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} + upload_url: '${{ steps.create_release.outputs.upload_url }}' steps: - id: 'create_release' uses: 'softprops/action-gh-release@v1'