Jump to content

GitHub Action that will build a pyromod


andy5995
 Share

Recommended Posts

20 hours ago, smiley said:

Perhaps a brief tutorial on this thread is warranted for those unfamiliar with Github actions.

I can try to make things a bit more clear, but I'm not sure a tutorial is warranted at this point. There's already docs on building a pyromod, github actions, and docker.

 

So... this thread is intended for anyone who hosts a mod on GitHub and want a bit of convenience when doing a release. Or this thread is intended for anyone thinking about hosing a mod on GitHub. People who don't use GitHub to mod will have no use for this action and can safely ignore this thread. :)

 

The docs for using the Action on the repo README. It assumes the root directory of your mod is in the repo root (e.g., the repo root is where 'mod.json' is located) When the action runs, it will create the mod using the pyrogenesis archive builder as shown here, and output the resulting .pyromod file to $PWD/output. An example is shown on the README on how to access it so it can be used in a separate release action. The release action shown in the example is not required to use the gh-action-build-pyromod action (there are other release actions available on GitHub that can be used instead, if you prefer)

 

20 hours ago, andy5995 said:

The Dockerfile I'm using for the Action is at 0ad-matters/0ad-bin-nodata

No technical knowledge of Docker is needed to use the Action. I posted this for anyone who is curious about the docker image used "behind-the-scenes" for the action, or for anyone who wants to "audit" how the image is created, or make a PR to improve upon it.

 

I'd be happy to answer any specific questions related to the Action.

How's that @smiley? ;)

Link to comment
Share on other sites

I think i got lost in so m any link and not sure what to do, (sorry im new to github and never used this things so maybe "more newbie text would be great" 

My understanding is this should create pyromod from provided source somehow automatically.

 

I created mentioned yml file https://github.com/Kampot-0ad/customrating/blob/main/.github/workflows/create_pyromod.yml

Now I can see in "action" menu new workflow "Build Pyromod" but no idea how to execute it.

lJ4Pzrg.png

 

Questions:

- Do I need to edit anything in "Releases" or "Packages"? There is Publish your first package

fG7qkkl.png

 

Link to comment
Share on other sites

10 minutes ago, Stan` said:

You only have v0.26.1 as tag so you need to use that.

Does not ring the bell, it seems to me it tries to use some "uses" outside of my github. my product tags does not matter I guess otherwise this automation would not make sense.

name: Release PyroMod
uses: ncipollo/release-action@v1.1   <--- HERE IS PROBLEM
with:
allowUpdates: True
prerelease: False
artifacts: "output/${{ env.MOD_NAME }}*.*"
token: ${{ secrets.GITHUB_TOKEN }}
omitNameDuringUpdate: True
omitBodyDuringUpdate: True
Link to comment
Share on other sites

49 minutes ago, Kampot said:

Does not ring the bell, it seems to me it tries to use some "uses" outside of my github. my product tags does not matter I guess otherwise this automation would not make sense.

 

@KampotI made a couple mistakes in my docs. The release action should be 'ncipollo/release-action@v1` not `ncipollo/release-action@v1.1`

 

Link to comment
Share on other sites

@KampotI'm glad you got it working!

 

5 hours ago, Kampot said:

It works, thanks. Now I would love to understand how it really works :)

Since you're new to GitHub, I can understand how it could be confusing. It's the very first github action I made, and I've been using GitHub for several years.

 

I know you've already looked at the files in the build-pyromod repo. If you look at some of the links in the README, it might help you understand better.

 

They key element is the use of docker with the action. Note that Docker isn't required to make an action, but it can be very helpful.

 

If at some point you have some specific questions about how it's done, feel free to post here. Good luck!

Link to comment
Share on other sites

  • 2 weeks later...

I've updated the example. Using this, the mod will build when you push any new commits to your main (default) branch, or any time a pull request is opened or updated. The artifact will get uploaded to the workflow output page (where you can download it and inspect it if desired). You can see at this link near the top right:


 

Quote

 

Artifacts

    1

 

 

And at the bottom of the page is a zip file containing the mod (artifact).

 

If the event that triggered the workflow is the creation of a tag starting with 'v', the pyromod gets built and uploaded to the release page (behavior that was in the original example).

 

name: Build Pyromod

on:
  push:
    branches:
      - main
    tags:
      - v**
  pull_request:
    branches:
      - main

env:
  MOD_NAME: <your-mod>

jobs:
  build-pyromod:
    if: ${{ github.ref_type != 'tag' }}
    runs-on: ubuntu-latest
    env:
      MOD_VERSION: ${{ github.sha }}
    steps:
    - uses: actions/checkout@v3
    - uses:  0ad-matters/gh-action-build-pyromod@v1
      with:
        name: ${{ env.MOD_NAME }}
        version: ${{ env.MOD_VERSION }}
      id: build-pyromod
    - name: Upload Artifacts
      # Uploads artifacts (combined into a zip file) to the workflow output page
      uses: actions/upload-artifact@v3
      with:
        name: ${{ env.MOD_NAME }}-${{ env.MOD_VERSION }}
        path: "output/${{ env.MOD_NAME }}*.*"

  release-pyromod:
    if: ${{ github.ref_type == 'tag' }}
    runs-on: ubuntu-latest
    env:
      MOD_VERSION: ${{ github.ref_name }}
    steps:
    - uses: actions/checkout@v3
    - name: Massage Variables
      run: |
        echo "MOD_VERSION=${MOD_VERSION:1}" >> $GITHUB_ENV
    - uses:  0ad-matters/gh-action-build-pyromod@v1
      with:
        name: ${{ env.MOD_NAME }}
        version: ${{ env.MOD_VERSION }}
      id: build-pyromod
    - name: Create sha256sum
      run:  |
        OUTPUT_FILE="$MOD_NAME-$MOD_VERSION.pyromod"
        cd output
        sha256sum $OUTPUT_FILE > $OUTPUT_FILE.sha256sum
    - name: Release PyroMod
      uses: ncipollo/release-action@v1
      with:
        allowUpdates: True
        prerelease: False
        artifacts: "output/${{ env.MOD_NAME }}*.*"
        token: ${{ secrets.GITHUB_TOKEN }}
        omitNameDuringUpdate: True
        omitBodyDuringUpdate: True

 

Edited by andy5995
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...