Skip to content

Crée un artéfact distribuable d'une extension ou thème YesWiki

License

Notifications You must be signed in to change notification settings

thom4parisot/yeswiki-release-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

yeswiki-release-action

GitHub Action/GitLab Container to package YesWiki extensions and themes.

Install

Pre-requisite : [email protected] with composer, jq.

composer install

Usage

./package.sh <yeswiki-extension-path> <extension-name?> <extension-version?>

For example:

# with minimal arguments
/package.sh path/to/extension ./dist
# > extension-main.zip

# with explicit name and version
/package.sh path/to/extension ./dist yeswiki-extension-publication 2020-09-27-1
# > extension-publication-2020-09-27-1.zip

See Docker Setup to run it from everywhere, including a GitHub Action and a GitLab CI Runner.

Use it in a GitHub Action

# .github/workflows/main.yml
on:
  release: [published]

jobs:
  package:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Test and package the extension
      id: package
      # uses: yeswiki/release-action@v1
      uses: oncletom/yeswiki-release-action@v1

    - name: Upload zip file
      uses: actions/upload-release-asset@v1
      upload_url: ${{ github.event.release.upload_url }}
        asset_path: ./dist/${{ steps.release.outputs.archive-name }}
        asset_name: ${{ steps.release.outputs.archive-name }}
        asset_content_type: application/zip
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Upload md5 file
      uses: actions/upload-release-asset@v1
      # ...

See it in action in yeswiki/yeswiki-extension-publication.

Use it in a GitLab CI Runner

# .gitlab-ci.yml
variables:
  PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/CI_PROJECT_NAME/${CI_COMMIT_REF_NAME}"

package:
  stage: package
  image: ghcr.io/oncletom/yeswiki-release-action:latest
  script:
    - /package.sh $CI_PROJECT_DIR $CI_PROJECT_NAME $CI_COMMIT_REF_NAME
  artifacts:
    name: $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG
    paths:
      - dist/*
    reports:
      dotenv: dist/variables.env

upload:
  stage: release
  image: curlimages/curl:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - |
        curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/${ARCHIVE_NAME} ${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}
    - |
        curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/${ARCHIVE_NAME}.md5 ${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}.md5

release:
  stage: upload
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "Create release $RELEASE_NAME $RELEASE_VERSION"
  release:
    name: "$RELEASE_NAME $RELEASE_VERSION"
    description: "Release $RELEASE_NAME $RELEASE_VERSION"
    tag_name: "$CI_COMMIT_TAG"
    assets:
      links:
      - name: "$ARCHIVE_NAME"
        url: "${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}"
        link_type: package
      - name: "$ARCHIVE_NAME.md5"
        url: "${PACKAGE_REGISTRY_URL}/${ARCHIVE_NAME}.md5"
        link_type: other

See it in action in oncletom/yeswiki-extension-test.

Docker setup

docker build -t yeswiki/yeswiki-release .
docker run --rm -v $(pwd)/yeswiki-extension-test:/yeswiki-extension-test yeswiki/yeswiki-release yeswiki-extension-test

Roadmap