From 71ff477bb9007bcf22cb41d055d0406e432517e0 Mon Sep 17 00:00:00 2001 From: "Robin C. Ladiges" Date: Wed, 13 Jul 2022 00:01:23 +0200 Subject: [PATCH] github workflow to build and release --- .github/actions/attach/action.yml | 40 ++++++++++++++++++++ .github/actions/build/action.yml | 61 ++++++++++++++++++++++++++++++ .github/actions/release/action.yml | 36 ++++++++++++++++++ .github/workflows/build.yml | 26 +++++++++++++ .github/workflows/release.yml | 47 +++++++++++++++++++++++ 5 files changed, 210 insertions(+) create mode 100644 .github/actions/attach/action.yml create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/release/action.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/attach/action.yml b/.github/actions/attach/action.yml new file mode 100644 index 0000000..cbcefea --- /dev/null +++ b/.github/actions/attach/action.yml @@ -0,0 +1,40 @@ +name: Attach build artifacts to release + + +inputs: + filename: + description : 'Filename of the build artifact' + required : true + upload_url: + description : 'Upload URL of the release' + required : true + GITHUB_TOKEN: + description : 'Secret GitHub token required for uploading to the release' + required : true + + +runs: + using: composite + steps: + - + name : Download artifacts + uses : actions/download-artifact@v3 + with: + name : ${{ inputs.filename }} + path : ./starlight_patch_100/ + - + name : Zip artifacts + shell : bash + run: | + cd ./starlight_patch_100/ + zip -rmT9 ${{ inputs.filename }}.zip ./* + - + name : Attach to release + uses : actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + with: + upload_url : ${{ inputs.upload_url }} + asset_path : ./starlight_patch_100/${{ inputs.filename }}.zip + asset_name : ${{ inputs.filename }}.zip + asset_content_type : application/zip diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..9adf5e3 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,61 @@ +name: Build artifacts + + +inputs: + tag: + description : 'version tag' + required : false + default : '' + + +outputs: + filename: + description : 'Filename for the build artifacts' + value : ${{ steps.env.outputs.filename }} + + +runs: + using: composite + steps: + - + name : Environment + id : env + shell : bash + run: | + VERS=${{ inputs.tag }} + echo "::set-output name=version::${VERS:1}" + echo "::set-output name=filename::SMO_Online${{ (inputs.tag != '' && format('_{0}', inputs.tag)) || '' }}" + - + name : Set up Docker Buildx + uses : docker/setup-buildx-action@v2 + - + name : Build environment + uses : docker/build-push-action@v3 + with: + pull : true + push : false + load : true + context : . + file : ./Dockerfile + tags : smoo-build-env + platforms : linux/amd64 + cache-from : type=gha,scope=smoo-build-env + cache-to : type=gha,scope=smoo-build-env,mode=max + - + name : Build mod + shell : bash + run: | + docker run --rm \ + -u `id -u`:`id -g` \ + -v "/$PWD/":/app/ \ + ${{ (steps.env.outputs.version != '' && format('-e BUILDVER={0}', steps.env.outputs.version)) || '' }} \ + smoo-build-env \ + ; + cp -r ./romfs/ ./starlight_patch_100/atmosphere/contents/0100000000010000/. + - + name : Upload artifacts + uses : actions/upload-artifact@v3 + with: + name : ${{ steps.env.outputs.filename }} + path : ./starlight_patch_100/ + if-no-files-found : error diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..e0d5576 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,36 @@ +name: Create release + + +inputs: + tag: + description : 'Version tag' + required : true + GITHUB_TOKEN: + description : 'Secret GitHub token required to create the release' + required : true + + +outputs: + id: + value: ${{ steps.release.outputs.id }} + html_url: + value: ${{ steps.release.outputs.html_url }} + upload_url: + value: ${{ steps.release.outputs.upload_url }} + + +runs: + using: composite + steps: + - + name : Create release + id : release + uses : actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + with: + tag_name : ${{ inputs.tag }} + release_name : Release ${{ inputs.tag }} + body : '' + draft : true + prerelease : false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f954ed7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build + + +on: + push: + branches: + - '**' + tags: + - '**' + - '!v[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: + - '**' + + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - + name : Checkout + uses : actions/checkout@v3 + - + name : Build artifacts + uses : ./.github/actions/build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..00c84b6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + + +jobs: + + build: + runs-on: ubuntu-latest + outputs: + filename: ${{ steps.build.outputs.filename }} + steps: + - + name : Checkout + uses : actions/checkout@v3 + - + name : Build artifacts + id : build + uses : ./.github/actions/build + with: + tag : ${{ github.ref_name }} + + release: + needs: build + runs-on: ubuntu-latest + steps: + - + name : Checkout + uses : actions/checkout@v3 + - + name : Create release + id : release + uses : ./.github/actions/release + with: + tag : ${{ github.ref_name }} + GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} + - + name : Attach build artifacts to release + uses : ./.github/actions/attach + with: + filename : ${{ needs.build.outputs.filename }} + upload_url : ${{ steps.release.outputs.upload_url }} + GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}