Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Updated CI/CD to make release once and with all artifacts at once.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMakarov committed Aug 29, 2023
1 parent fca64d3 commit 6797b66
Showing 1 changed file with 52 additions and 21 deletions.
73 changes: 52 additions & 21 deletions .github/workflows/github-actions-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ jobs:
- name: Test
run: go test ./...

# Job to release artifacts only if tag was pushed.
build_and_release:
# Job to build artifacts only if tag was pushed.
build:
needs: check_code
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

# Run concurrently for all major OS-es and architectures.
strategy:
matrix:
os: [windows, darwin, linux]
Expand Down Expand Up @@ -81,18 +82,12 @@ jobs:
else
git log --pretty="- %s" -q --no-color >> body.log
fi
line_count=$(cat body.log | wc -l)
echo "version=${version}" >> $GITHUB_OUTPUT
echo "curtag=$curtag" >> $GITHUB_OUTPUT
echo "prevtag=$prevtag" >> $GITHUB_OUTPUT
echo "line_count=$line_count" >> $GITHUB_OUTPUT
- run: echo version is ${{ steps.vars.outputs.version }}
- run: echo curtag is ${{ steps.vars.outputs.curtag }}
- run: echo prevtag is ${{ steps.vars.outputs.prevtag }}
- run: echo line_count is ${{ steps.vars.outputs.line_count }}
- run: cat body.log
- name: Print resulting information
run: |
echo version is ${{ steps.vars.outputs.version }}
cat body.log
- name: Build Binaries
run: |
Expand All @@ -101,16 +96,52 @@ jobs:
-ldflags "-X main.Version=$${{ steps.vars.outputs.version }}"
chmod a+x aggregate-inecobank-statements-*
- name: Upload Binaries
- name: Save Version and Binaries
id: save_info
run: |
echo "${{ steps.vars.outputs.version }}" > version.txt
# Idea here that the last `ls` would overwrite content with all files list.
ls aggregate-inecobank-statements-* # For debugging.
echo "binaries=$(ls aggregate-inecobank-statements-*)" >> $GITHUB_ENV
# For debugging.
echo "GITHUB_ENV=$GITHUB_ENV"
cat ${GITHUB_ENV} || true
- name: Upload Binaries and Release data to artifacts
uses: actions/upload-artifact@v3
with:
name: data
# Note that each job "thread" would write it's own files here.
path: |
version.txt
body.log
${{ env.binaries }}
# Job to prepare artifacts only if they were built.
release:
needs: build
runs-on: ubuntu-latest
steps:

- name: Download Info Artifacts
uses: actions/download-artifact@v3
with:
name: data

- name: Read Version and Binaries
run: |
# Print what we have in the result.
ls -la
echo "--- version.txt ---"
cat version.txt
echo "--- body.log ---"
cat body.log
echo "version=$(cat version.txt)" >> $GITHUB_ENV
- name: Make Release in repo
uses: ncipollo/release-action@v1
with:
name: ${{ steps.vars.outputs.version }}
name: ${{ env.version }}
bodyFile: "body.log"
token: ${{ secrets.GHACTIONS_PUBLIC_REPO_RW }} # Note that it is custom PAT which expires.
artifacts: |
aggregate-inecobank-statements-linux-amd64
aggregate-inecobank-statements-linux-arm64
aggregate-inecobank-statements-windows-amd64.exe
aggregate-inecobank-statements-windows-arm64.exe
aggregate-inecobank-statements-darwin-arm64
aggregate-inecobank-statements-darwin-arm64
artifacts: aggregate-inecobank-statements-*

0 comments on commit 6797b66

Please sign in to comment.