GitHub Action/GitLab Container to package YesWiki extensions and themes.
Pre-requisite : [email protected]
with composer
, jq
.
composer install
./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.
# .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: yeswiki/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.
# .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/yeswiki/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 thom4parisot/yeswiki-extension-test.
docker build -t yeswiki/yeswiki-release .
docker run --rm -v $(pwd)/yeswiki-extension-test:/yeswiki-extension-test yeswiki/yeswiki-release yeswiki-extension-test
- Make it work with GitHub Actions
- Make it work with GitLab CI
- Infer extension name from
composer.json
- Notify YesWiki extension registry