From d22745c7b2dfde62d9c6d52cfc644a2e8c375a45 Mon Sep 17 00:00:00 2001 From: Rapidement Date: Fri, 14 Jun 2024 09:41:40 +0200 Subject: [PATCH] Fix/ci (#126) updated staging CI --- .github/workflows/build-staging.yml | 62 +++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 10fee440..9eb700fb 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -1,19 +1,22 @@ -name: Gigwa Build Staging +name: Gigwa Build Staging test on: push: tags: - - '*-STAGING' + - 'STAGING' jobs: - build: + pre-realese: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4.1.6 + - name: Set up Java uses: actions/setup-java@v4.2.1 with: distribution: 'zulu' java-version: 17 - - name: Run build script + - name: Build project run: | wget https://raw.githubusercontent.com/${{ github.repository }}/staging/misc/build-staging.sh chmod +x build-staging.sh @@ -21,17 +24,7 @@ jobs: pwd ls - - name: Upload Webapp Artifact - uses: actions/upload-artifact@v4 - with: - path: ${{ github.event.repository.name }}/target/Gigwa_V*_Webapp.zip - name: Gigwa_Webapp.zip - if-no-files-found: error - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Delete release and tag + - name: Delete old prelease and tag env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -42,7 +35,7 @@ jobs: RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME" \ | jq -r '.id') - + if [ "$RELEASE_ID" != "null" ]; then echo "Deleting release with ID $RELEASE_ID" # Delete the release @@ -57,6 +50,43 @@ jobs: # Delete the tag from the remote repository git push origin :refs/tags/$TAG_NAME + - name: Set up variables + id: vars + run: | + echo "DATE=$(date +'%d/%m/%y')" >> $GITHUB_ENV + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "NEW_NAME=Gigwa2_STAGING" >> $GITHUB_ENV + + - name: Create prerelease + id: create_release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "STAGING" + release_name: "STAGING" + draft: false + prerelease: true + body: "This is a staging prerelease ${{ env.DATE }} ${{ env.SHORT_SHA }}" + + - name: Grep release version + id: grep_release_version + run: | + # RESULT=$(grep -m 1 project\\\.version ${{ github.event.repository.name }}/pom.xml | sed -n 's/.*\(.*\)<\/project\.version>.*/\1/p') + echo "release_version=$(grep -m 1 project\\\.version ${{ github.event.repository.name }}/pom.xml | sed -n 's/.*\(.*\)<\/project\.version>.*/\1/p')" >>$GITHUB_OUTPUT + shell: bash + + - name: Upload main prerelease asset (webapp zip) + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.event.repository.name }}/target/Gigwa_V${{ steps.grep_release_version.outputs.release_version }}_Webapp.zip + asset_name: ${{ env.NEW_NAME }}.zip + asset_content_type: application/zip + # ssh: # runs-on: ubuntu-latest # needs: build