omeka / omeka-s-developer

Documentation for Omeka S developers
Other
18 stars 37 forks source link

Module documentation enhancement #69

Open jaredhowland opened 1 year ago

jaredhowland commented 1 year ago

Github now allows you to use actions that could create a release and attach a zipped version of the module for you. Putting an example action in the documentation (docs/register_an_addon.md) might be very helpful. Here is the one I use for the Any Cloud module. You create a tag with the version of the module you want to create a release for (v2.2.3 for example) and the action takes over from there:

.github/workflows/release.yml

name: Release
on:
  push:
    tags:
      - '*'
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: "Checkout repository"
        uses: "actions/checkout@master"
      - name: "Set up PHP"
        uses: "shivammathur/setup-php@v2"
        with:
          php-version: "latest"
      - name: "Composer install"
        uses: "ramsey/composer-install@v2"
        with:
          composer-options: "--ignore-platform-reqs --optimize-autoloader"
      - name: "Create archive release"
        uses: "thedoctor0/zip-release@master"
        with:
          filename: "{AddonZipName}.zip"
          exclusions: "*.git* .tx/ language/*.po* .editorconfig phpcs.xml.dist"
      - name: Upload Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: '{AddonZipName}.zip'
          bodyFile: "RELEASE.md"
          token: ${{ secrets.GITHUB_TOKEN }}

It downloads composer, installs the versions of the dependencies indicated in your composer.lock file in the repository, zips everything up except what you put in the exclusions section, and adds the text of RELEASE.md as the text of the release.

In any case, this might be helpful to other developers and make things a little easier than manually uploaded a .zip file to every release. Creating a git tag for a release and letting GitHub do all the other work is really helpful.

jaredhowland commented 1 year ago

I've updated this a little because the zip file wasn't zipping the top-level directory:

name: Release
on:
  push:
    tags:
      - '*'
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: "Checkout repository"
        uses: "actions/checkout@master"
        with:
            path: "{MODULE_NAME}/"
      - name: "Set up PHP"
        uses: "shivammathur/setup-php@v2"
        with:
          php-version: "latest"
      - name: "Composer install"
        uses: "ramsey/composer-install@v2"
        with:
          working-directory: "{MODULE_NAME}/"
          composer-options: "--ignore-platform-reqs --optimize-autoloader"
      - name: "Create archive release"
        uses: "thedoctor0/zip-release@master"
        with:
          filename: "{MODULE_NAME}.zip"
          exclusions: "{MODULE_NAME}/*.git* {MODULE_NAME}/UpdateModuleIni.php {MODULE_NAME}/.editorconfig {MODULE_NAME}/.scrutinizer.yml {MODULE_NAME}/CODE_OF_CONDUCT.md {MODULE_NAME}/CONTRIBUTING.md {MODULE_NAME}/CONTRIBUTORS.md {MODULE_NAME}/RELEASE.md {MODULE_NAME}/phpcs.xml.dist"
      - name: "Upload Release"
        uses: "ncipollo/release-action@v1"
        with:
          artifacts: "{MODULE_NAME}.zip"
          bodyFile: "{MODULE_NAME}/RELEASE.md"
          token: ${{ secrets.GITHUB_TOKEN }}