From ffb384a6729921b318f386852c1a4c8a065cb74a Mon Sep 17 00:00:00 2001 From: Taher Kathanawala Date: Mon, 5 May 2025 19:59:12 +0530 Subject: [PATCH 1/4] add github action --- .github/workflow/release.yaml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflow/release.yaml diff --git a/.github/workflow/release.yaml b/.github/workflow/release.yaml new file mode 100644 index 0000000..2e095b6 --- /dev/null +++ b/.github/workflow/release.yaml @@ -0,0 +1,52 @@ +on: + push: + tags: "v*" + workflow_dispatch: + +permissions: + content: write + +jobs: + download-asset: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install GitHub CLI + run: sudo apt-get update && sudo apt-get install gh -y + + - name: Download asset from latest release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh auth status + gh release download \ + --repo StackGuardian/golang-runner-service \ + --pattern 'golang-runner-service_Linux_x86_64.tar.gz' \ + --dir ./downloaded-assets + + - name: combine files in a directory + run: | + mkdir combined + cp main.sh ./combined/main.sh + cp downloaded-assets/sgrunner ./combined/assests + ls + ls combined + + - name: Determine if prerelease + id: check_prerelease + run: | + TAG_NAME="${GITHUB_REF##*/}" + if [[ "$TAG_NAME" == *-* ]]; then + echo "is_prerelease=true" >> $GITHUB_OUTPUT + else + echo "is_prerelease=false" >> $GITHUB_OUTPUT + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 44f3b0b41fc6f013e691d851fea7226dda072bf6 Mon Sep 17 00:00:00 2001 From: Taher Kathanawala Date: Tue, 6 May 2025 20:11:07 +0530 Subject: [PATCH 2/4] github action to release with golang service --- .github/workflow/release.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflow/release.yaml b/.github/workflow/release.yaml index 2e095b6..1722102 100644 --- a/.github/workflow/release.yaml +++ b/.github/workflow/release.yaml @@ -1,10 +1,13 @@ +name: Release + on: push: - tags: "v*" + tags: + - "v*" workflow_dispatch: permissions: - content: write + contents: write jobs: download-asset: @@ -18,7 +21,7 @@ jobs: - name: Download asset from latest release env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.TAHER_PAT }} run: | gh auth status gh release download \ @@ -28,12 +31,10 @@ jobs: - name: combine files in a directory run: | - mkdir combined - cp main.sh ./combined/main.sh - cp downloaded-assets/sgrunner ./combined/assests - ls - ls combined - + tar -xvf downloaded-assets/golang-runner-service_Linux_x86_64.tar.gz + mkdir dist + cp main.sh sgrunner ./dist/ + zip sgrunner.zip dist/* - name: Determine if prerelease id: check_prerelease run: | @@ -48,5 +49,6 @@ jobs: uses: softprops/action-gh-release@v1 with: prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }} + files: sgrunner.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From c3eeca6aa92efd1bf1b63cecb7a0695c5fb7119b Mon Sep 17 00:00:00 2001 From: Taher Kathanawala <28436188+taherkk@users.noreply.github.com> Date: Mon, 19 May 2025 16:14:06 +0530 Subject: [PATCH 3/4] add formatting --- .github/workflow/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflow/release.yaml b/.github/workflow/release.yaml index 1722102..e562566 100644 --- a/.github/workflow/release.yaml +++ b/.github/workflow/release.yaml @@ -35,6 +35,7 @@ jobs: mkdir dist cp main.sh sgrunner ./dist/ zip sgrunner.zip dist/* + - name: Determine if prerelease id: check_prerelease run: | From d25337b3b283a833c4212c42c84179831e48a47f Mon Sep 17 00:00:00 2001 From: Taher Kathanawala Date: Wed, 28 May 2025 15:09:49 +0530 Subject: [PATCH 4/4] push tar.gz to s3 instead of github release --- .github/workflow/release.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflow/release.yaml b/.github/workflow/release.yaml index e562566..e3ab285 100644 --- a/.github/workflow/release.yaml +++ b/.github/workflow/release.yaml @@ -46,10 +46,13 @@ jobs: echo "is_prerelease=false" >> $GITHUB_OUTPUT fi - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 with: - prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }} - files: sgrunner.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 # change to your region + + - name: Upload to S3 + run: | + aws s3 cp ./sgrunner.tar.gz s3://sgrunner-bundle/ --content-type application/gzip \ No newline at end of file