diff --git a/.github/actions/repo-state/action.yml b/.github/actions/repo-state/action.yml new file mode 100644 index 00000000..597e6b36 --- /dev/null +++ b/.github/actions/repo-state/action.yml @@ -0,0 +1,51 @@ +name: 'Repository state' +description: 'Get the latest tag, the latest process-note, the number of commits since the last tag and the version numbers from the last tag.' +outputs: + tag: + description: "Last tagged version" + value: ${{ steps.tag.outputs.value }} + note: + description: "Note on the last tag" + value: ${{ steps.note.outputs.value }} + commits: + description: "Number of commits since the last tag" + value: ${{ steps.commits.outputs.value }} + version_major: + description: "Major version number" + value: ${{ steps.version.outputs.major }} + version_minor: + description: "Minor version number" + value: ${{ steps.version.outputs.minor }} + version_revision: + description: "Revision number" + value: ${{ steps.version.outputs.revision }} +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: 'master' + - name: Get the last release-tag + id: tag + shell: bash + run: echo "value=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT + - name: Get the note on the last release-tag + id: note + shell: bash + run: | + git fetch origin refs/notes/*:refs/notes/* + echo 'value<> $GITHUB_OUTPUT + (git notes show $(git describe --tags --abbrev=0) | cat || true) >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + - name: Get the commits since the last tag + id: commits + shell: bash + run: echo "value=$(git rev-list --count $(git describe --tags --abbrev=0)..HEAD)" >> $GITHUB_OUTPUT + - name: Get the version numbers + id: version + shell: bash + run: | + echo "major=$(git describe --tags --abbrev=0 | sed 's@^[^0-9]*\([0-9]\+\).*@\1@;tx;s/.*/0/;:x')" >> $GITHUB_OUTPUT + echo "minor=$(git describe --tags --abbrev=0 | sed 's@^[^0-9]*[0-9]*[.]\([0-9]\+\).*@\1@;tx;s/.*/0/;:x')" >> $GITHUB_OUTPUT + echo "revision=$(git describe --tags --abbrev=0 | sed 's@^[^0-9]*[0-9]*[.][0-9]*[.]\([0-9]\+\).*@\1@;tx;s/.*/0/;:x')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..8d30fedc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,103 @@ +name: Build + +on: + workflow_call: + inputs: + godot-version: + required: true + type: string + ubuntu-version: + required: true + type: string + outputs: + checksum: + description: "md5 sums of the generated output files" + value: ${{ jobs.build.outputs.checksum }} + +jobs: + build: + runs-on: ubuntu-${{ inputs.ubuntu-version }} + outputs: + checksum: ${{ steps.final.outputs.checksum }} + steps: + - uses: actions/checkout@v4 + - name: Restore cached dependencies + uses: actions/cache/restore@v4 + id: cache-godot + with: + path: | + Godot_v${{ inputs.godot-version }}-stable_linux_headless.64.zip + Godot_v${{ inputs.godot-version }}-stable_export_templates.tpz + key: ${{ runner.os }}-${{ inputs.ubuntu-version }}-${{ inputs.godot-version }} + - name: Download Godot and its Export Templates + if: steps.cache-godot.outputs.cache-hit != 'true' + run: | + wget -q https://downloads.tuxfamily.org/godotengine/${{ inputs.godot-version }}/Godot_v${{ inputs.godot-version }}-stable_linux_headless.64.zip + wget -q https://downloads.tuxfamily.org/godotengine/${{ inputs.godot-version }}/Godot_v${{ inputs.godot-version }}-stable_export_templates.tpz + - name: Add dependencies to the cache if necessary + if: steps.cache-godot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: | + Godot_v${{ inputs.godot-version }}-stable_linux_headless.64.zip + Godot_v${{ inputs.godot-version }}-stable_export_templates.tpz + key: ${{ steps.cache-godot.outputs.cache-primary-key }} + - name: Install Godot and the export templates + run: | + unzip Godot_v${{ inputs.godot-version }}-stable_linux_headless.64.zip + rm Godot_v${{ inputs.godot-version }}-stable_linux_headless.64.zip + unzip Godot_v${{ inputs.godot-version }}-stable_export_templates.tpz + rm Godot_v${{ inputs.godot-version }}-stable_export_templates.tpz + mkdir -v -p ~/.local/share/godot/templates/${{ inputs.godot-version }}.stable/ + mv templates/* ~/.local/share/godot/templates/${{ inputs.godot-version }}.stable/ + ls ~/.local/share/godot/templates/${{ inputs.godot-version }}.stable/ + - name: Install mingw + run: sudo apt-get install gcc-mingw-w64 + - name: Create the output directories + run: | + mkdir output + mkdir output/burrito_link + - name: Build X11_FG + run: | + cd burrito-fg + cargo build --release + - name: Build taco_parser + run: | + cd taco_parser + cargo build --release + - name: Build Burrito Link + run: | + mkdir burrito_link/build + cd burrito_link/build + cmake .. + make + - name: Build Burrito + run: | + mkdir build + ./Godot_v${{ inputs.godot-version }}-stable_linux_headless.64 --export "Linux/X11" + chmod +x build/burrito.x86_64 + - name: Fill the output folder + run: | + mv burrito_link/build/burrito_link.exe output/burrito_link + mv burrito_link/build/d3d11.dll output/burrito_link + mv build/burrito.x86_64 output/ + mv build/libburrito_fg.so output/ + mv build/libgw2_taco_parser.so output/ + - name: Upload output folder as an artifact + uses: actions/upload-artifact@v4 + id: artifact-upload + with: + name: burrito-binaries + path: output + if-no-files-found: error + overwrite: true + - name: Strip the burrito_link binaries for reproducibility + run: strip output/burrito_link/* + - name: Get the md5 sums for the produced output files + id: final + run: | + mv output/burrito_link/* output/ + rm -rf output/burrito_link + echo 'checksum<> $GITHUB_OUTPUT + md5sum output/* >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 00000000..79f52b8a --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,12 @@ +name: CI + +on: + pull_request: + branches: [ "*" ] + +jobs: + Build: + uses: ./.github/workflows/build.yml + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 7a53084d..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,122 +0,0 @@ -# This workflow will compile the burrio_link and export the burrito binary -# the two files will be available as an artifact. - -name: CI - - -env: - # The version of Godot to use - GODOT_VERSION: 3.3.2 - - # Used as a makeshift cache expiry - CACHE_STRING: "Zo6AbxJk4KQl0sGE" - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ "*" ] - pull_request: - branches: [ "*" ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - Build-Linux: - # The type of runner that the job will run on - runs-on: ubuntu-20.04 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v2 - - # - name: Update Packages - # run: sudo apt-get update && sudo apt-get upgrade - - # - name: Cache Godot - # id: cache-godot - # uses: actions/cache@v2 - # with: - # path: ./Godot_v${GODOT_VERSION}-stable_linux_headless.64 - # key: ${{ runner.os }}-godot-${GODOT_VERSION}-${CACHE_STRING} - - # - - name: Download Godot - # if: steps.cache-godot.outputs.cache-hit != 'true' - run: | - wget -q https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip - unzip Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip - rm Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip - - # - name: Cache Godot Templates - # id: cache-godot-templates - # uses: actions/cache@v2 - # with: - # path: ~/.local/share/godot/templates/${GODOT_VERSION}.stable/ - # key: ${{ runner.os }}-godot-${GODOT_VERSION}-${CACHE_STRING} - - - - name: Download Godot Export Templates - # if: steps.cache-godot-templates.outputs.cache-hit != 'true' - run: | - mkdir -v -p ~/.local/share/godot/templates/${GODOT_VERSION}.stable/ - - wget -q https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz - - unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz - mv templates/* ~/.local/share/godot/templates/${GODOT_VERSION}.stable/ - ls ~/.local/share/godot/templates/${GODOT_VERSION}.stable/ - - - - name: Install mingw - run: sudo apt-get install gcc-mingw-w64 - - - # Runs a single command using the runners shell - - name: Create the Output Directory - run: mkdir output - - - name: Build X11_FG - run: | - cd burrito-fg - cargo build --release - - - name: Build taco_parser - run: | - cd taco_parser - cargo build --release - - - name: Build Burrito Link - run: | - mkdir output/burrito_link - mkdir burrito_link/build - cd burrito_link/build - cmake .. - make - mv burrito_link.exe ../../output/burrito_link - mv d3d11.dll ../../output/burrito_link - - - - name: Build Burrito - run: | - mkdir build - ./Godot_v${GODOT_VERSION}-stable_linux_headless.64 --export "Linux/X11" - chmod +x build/burrito.x86_64 - mv build/burrito.x86_64 output/ - mv build/libburrito_fg.so output/ - mv build/libgw2_taco_parser.so output/ - - - - uses: actions/upload-artifact@v2.2.4 - with: - # Artifact name - name: "Burrito_Linux" # optional, default is artifact - # A file, directory or wildcard pattern that describes what to upload - path: "output/*" - # The desired behavior if no files are found using the provided path. - if-no-files-found: error - # Duration after which artifact will expire in days. 0 means using default retention. - retention-days: 0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..2bd605b8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,57 @@ +name: Publish + +on: + workflow_call: + inputs: + artifact-name: + required: true + type: string + release-message: + type: string + add-commits: + type: string + checksum: + type: string + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github + - name: Get the repository state + uses: ./.github/actions/repo-state + id: repo-state + - name: Download all available artifacts + uses: actions/download-artifact@v4 + - name: Zip the output files for deployment + run: (cd burrito-binaries && zip -r ../${{ inputs.artifact-name }} .) + - name: Handle the manually entered release message if it exists + if: inputs.release-message != '' + run: | + echo "${{ inputs.release-message }}" >> release-notes-tmp + echo "" >> release-notes-tmp + - name: Create an automatic release message if requested or necessary + id: release-message-auto + if: inputs.release-message == '' || inputs.add-commits == 'true' + uses: simbo/changes-between-tags-action@v1 + with: + tag-pattern: '^([a-z]+)?-[0-9]+\.[0-9]+\.?([0-9]+)?$' + validate-tag: 'false' + - name: Handle the automatically generated release message if requested or necessary + if: inputs.release-message == '' || inputs.add-commits == 'true' + run: echo "${{ steps.release-message-auto.outputs.changes }}" >> release-notes-tmp + - name: Create and publish the final release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.repo-state.outputs.tag }} + artifacts: ${{ inputs.artifact-name }} + bodyFile: release-notes-tmp + - name: Write a git-note with all checksums to the latest release + run: | + git fetch origin refs/notes/*:refs/notes/* + git config user.email 'github-actions[bot]@users.noreply.github.com' + git config user.name 'github-actions[bot]' + git notes add -f -m "${{ inputs.checksum }}" $(git describe --tags --abbrev=0) + git push origin refs/notes/* diff --git a/.github/workflows/release_bugfix.yml b/.github/workflows/release_bugfix.yml new file mode 100644 index 00000000..ab5bdbaa --- /dev/null +++ b/.github/workflows/release_bugfix.yml @@ -0,0 +1,55 @@ +name: Release Bugfix + +on: + workflow_dispatch: + inputs: + message: + required: true + add-commits: + type: boolean + default: true + description: Add commit messages to your release message. + +jobs: + Check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github + - name: Get the repository state + uses: ./.github/actions/repo-state + id: repo-state + - name: Check if there are new commits to release or add one if necessary + if: steps.repo-state.outputs.commits <= 0 + run: | + echo "::warning ::There was nothing to release. So an empty commit was created automatically." + git config user.email 'github-actions[bot]@users.noreply.github.com' + git config user.name 'github-actions[bot]' + git commit --allow-empty -m "Auto commit for bugfix release." + git push origin + - name: Add a new release-tag + env: + VERSION_MAJOR: ${{ steps.repo-state.outputs.version_major }} + VERSION_MINOR: ${{ steps.repo-state.outputs.version_minor }} + VERSION_REVISION: ${{ steps.repo-state.outputs.version_revision }} + run: | + git tag release-$(( $VERSION_MAJOR )).$(( $VERSION_MINOR )).$(( $VERSION_REVISION +1 )) + git push origin release-$(( $VERSION_MAJOR )).$(( $VERSION_MINOR )).$(( $VERSION_REVISION +1 )) + + Build: + uses: ./.github/workflows/build.yml + needs: Check + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 + + Publish: + uses: ./.github/workflows/publish.yml + needs: Build + with: + artifact-name: Burrito_Linux.zip + release-message: ${{ github.event.inputs.message }} + add-commits: ${{ github.event.inputs.add-commits }} + checksum: ${{ needs.Build.outputs.checksum }} diff --git a/.github/workflows/release_major.yml b/.github/workflows/release_major.yml new file mode 100644 index 00000000..cf82c649 --- /dev/null +++ b/.github/workflows/release_major.yml @@ -0,0 +1,62 @@ +name: Release Major + +on: + workflow_dispatch: + inputs: + message: + required: true + add-commits: + type: boolean + default: true + description: Add commit messages to your release message. + +jobs: + Pre-Build: + uses: ./.github/workflows/build.yml + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 + + Check: + runs-on: ubuntu-latest + needs: Pre-Build + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github + - name: Get the repository state + uses: ./.github/actions/repo-state + id: repo-state + - name: Check if there are new commits to release + if: steps.repo-state.outputs.commits <= 0 + run: | + echo "::error ::There is nothing to release. We need at least one unreleased commit." + exit 1 + - name: Check if the binaries from the pre-build-job differ from the last release + if: steps.repo-state.outputs.note == needs.Pre-Build.outputs.checksum + run: | + echo "::error ::There is nothing to release. The produced binaries are exactly the same as in the latest release." + exit 1 + - name: Add a new release-tag + env: + VERSION_MAJOR: ${{ steps.repo-state.outputs.version_major }} + run: | + git tag release-$(( $VERSION_MAJOR + 1)).0.0 + git push origin release-$(( $VERSION_MAJOR + 1)).0.0 + + Build: + uses: ./.github/workflows/build.yml + needs: Check + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 + + Publish: + uses: ./.github/workflows/publish.yml + needs: Build + with: + artifact-name: Burrito_Linux.zip + release-message: ${{ github.event.inputs.message }} + add-commits: ${{ github.event.inputs.add-commits }} + checksum: ${{ needs.Build.outputs.checksum }} diff --git a/.github/workflows/release_minor.yml b/.github/workflows/release_minor.yml new file mode 100644 index 00000000..6700593e --- /dev/null +++ b/.github/workflows/release_minor.yml @@ -0,0 +1,55 @@ +name: Release Minor + +on: + schedule: + - cron: "0 13 * * 2" + +jobs: + Pre-Build: + uses: ./.github/workflows/build.yml + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 + + Check: + runs-on: ubuntu-latest + needs: Pre-Build + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github + - name: Get the repository state + uses: ./.github/actions/repo-state + id: repo-state + - name: Check if there are new commits to release + if: steps.repo-state.outputs.commits <= 0 + run: | + echo "::error ::There is nothing to release. We need at least one unreleased commit." + exit 1 + - name: Check if the binaries from the pre-build-job differ from the last release + if: steps.repo-state.outputs.note == needs.Pre-Build.outputs.checksum + run: | + echo "::error ::There is nothing to release. The produced binaries are exactly the same as in the latest release." + exit 1 + - name: Add a new release-tag + env: + VERSION_MAJOR: ${{ steps.repo-state.outputs.version_major }} + VERSION_MINOR: ${{ steps.repo-state.outputs.version_minor }} + run: | + git tag release-$(( $VERSION_MAJOR )).$(( $VERSION_MINOR +1 )).0 + git push origin release-$(( $VERSION_MAJOR )).$(( $VERSION_MINOR +1 )).0 + + Build: + uses: ./.github/workflows/build.yml + needs: Check + with: + godot-version: 3.3.2 + ubuntu-version: 20.04 + + Publish: + uses: ./.github/workflows/publish.yml + needs: Build + with: + artifact-name: Burrito_Linux.zip + checksum: ${{ needs.Build.outputs.checksum }}