diff --git a/.github/workflows/ci_fabric-stable.yml b/.github/workflows/ci_fabric-stable.yml index 00737b7..7e98176 100644 --- a/.github/workflows/ci_fabric-stable.yml +++ b/.github/workflows/ci_fabric-stable.yml @@ -28,9 +28,9 @@ jobs: - name: Build with Gradle run: ./gradlew build - name: Execute permission for renaming script - run: chmod +x ./.github/workflows/renaming.sh - - name: Running renaming script - run: ./.github/workflows/renaming.sh + run: chmod +x ./.github/workflows/main.sh + - name: Running main script + run: ./.github/workflows/main.sh # Artifact upload - name: Uploading artifacts @@ -39,3 +39,29 @@ jobs: #name: ${{ env.BUILDNAME }}.jar name: UNZIP_ME_${{ env.BUILDNAME }} path: build/libs/${{ env.BUILDNAME }}.jar + - name: Create a Release + if: ${{ env.SHOULD_PUBLISH }} + id: create_release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # The name of the tag. This should come from the webhook payload, `github.GITHUB_REF` when a user pushes a new tag + tag_name: ${{ env.VERSION }} + # The name of the release. For example, `Release v1.0.1` + release_name: SimpleAuth ${{ env.VERSION }} + # Text describing the contents of the tag. + body: This release was created automatically, since version was bumped. Should be stable unless I messed up something. + - name: Upload a Release Asset + if: ${{ env.SHOULD_PUBLISH }} + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # The URL for uploading assets to the release + upload_url: ${{ steps.create_release.outputs.upload_url }} + # The path to the asset you want to upload + asset_path: build/libs/${{ env.BUILDNAME }}.jar + # The name of the asset you want to upload + asset_name: ${{ env.BUILDNAME }} + asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/main.sh b/.github/workflows/main.sh new file mode 100644 index 0000000..0a145b7 --- /dev/null +++ b/.github/workflows/main.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Setting the variables +projectId="$(grep 'archives_base_name' gradle.properties | sed 's/archives_base_name = //g;s/ //g;s/,//g;s/"//g')" +version="$(grep 'mod_version' gradle.properties | grep -o '[0-9]*\.[0-9]*\.[0-9]*')" +mcVersion="$(grep 'minecraft_version' gradle.properties | sed 's/minecraft_version=//g;s/ //g;s/,//g;s/"//g')" + +cd ./build/libs || exit + +buildName="$projectId-$version-devbuild_$GITHUB_RUN_NUMBER-MC_$mcVersion" + +echo "Build is going to be renamed: $buildName.jar" +# Renaming the dev build +mv "$projectId-$version-$mcVersion.jar" "$buildName.jar" + +# Setting the buildname for GH actions +echo "BUILDNAME=$buildName" >> $GITHUB_ENV +echo "PROJECT_ID=$projectId" >> $GITHUB_ENV +echo "VERSION=$version" >> $GITHUB_ENV +echo "MC_VERSION=$mcVersion" >> $GITHUB_ENV + + +# Checks if build is stable (I always bump version when I release stable, uploadable version) +latestRelease=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" | grep -oP '"tag_name": "\K(.*)(?=")') +echo "Latest release is: $latestRelease" + + +if [ "$latestRelease" == "$version" ]; then + echo "No need to publish release. Not necesarry stable yet." +else + echo "Hooray! New release!" + echo "SHOULD_PUBLISH=true" >> $GITHUB_ENV +fi \ No newline at end of file diff --git a/.github/workflows/renaming.sh b/.github/workflows/renaming.sh deleted file mode 100644 index 19ce17a..0000000 --- a/.github/workflows/renaming.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Setting the variables -projectId="$(grep 'archives_base_name' gradle.properties | sed 's/archives_base_name = //g;s/ //g;s/,//g;s/"//g')" -version="$(grep 'mod_version' gradle.properties | grep -o '[0-9]*\.[0-9]*\.[0-9]*')" -mcVersion="$(grep 'minecraft_version' gradle.properties | sed 's/minecraft_version=//g;s/ //g;s/,//g;s/"//g')" - -cd ./build/libs || exit - -buildName="$projectId-$version-devbuild_$GITHUB_RUN_NUMBER-MC_$mcVersion" - -echo "Build is going to be renamed: $buildName.jar" -# Renaming the dev build -mv "$projectId-$version-$mcVersion.jar" "$buildName.jar" - -#Setting the buildname for GH actions -echo "::set-env name=BUILDNAME::$buildName"