Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
t-tani committed Apr 16, 2024
0 parents commit a8bf1c1
Show file tree
Hide file tree
Showing 33 changed files with 5,735 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and deploy docs

on:
push:
branches:
- main

jobs:

build_docs:
name: Build docs and deploy to gh-pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Restore pip cache
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ubuntu-latest-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}

- name: Install dependencies
run: |
pip install -e .
pip install pdoc3
- name: Build docs
run: |
mkdir -p docs
pdoc pypowerautomate --html -o html --force
cp -rf html/pypowerautomate/* docs/
- name: Deploy on gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }}
CLEAN: true
122 changes: 122 additions & 0 deletions .github/workflows/upload_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Build and publish package to PyPI and TestPyPI

on:
push:
branches:
- main
release:
types:
- created

jobs:
build_package:
name: Build pypi pacakge
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Restore pip cache
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ubuntu-latest-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}

- name: Install pypa/build
run: |
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

# publish-to-testpypi:
# name: Publish to TestPyPI
# needs:
# - build_package
# runs-on: ubuntu-latest

# environment:
# name: testpypi
# url: https://test.pypi.org/p/pypowerautomate

# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing

# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v3
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
needs:
- build_package
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pypowerautomate
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


github-release:
name: Sign the package with Sigstore and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v1.2.3
with:
inputs: |
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}

run: |
gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# pyenv
.python-version

# powerautomate artifacts
/*.zip
Microsoft.Flow/*

# html contents
/docs/*
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright 2024 NTT Security (Japan) KK

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# PyPowerAutomate

*PyPowerAutomate is not affiliated with Microsoft Corporation.*

## Overview

PyPowerAutomate is a Python package designed for creating, managing, and deploying Microsoft Power Automate Flows programmatically. This library provides a simple and efficient way to define Power Automate Flows in JSON format directly from Python code. Whether you're an automation expert, a developer looking to integrate Power Automate into your Python projects, or an enthusiast exploring the realms of workflow automation, Power Automate Library is your go-to tool.

## Features

- **Flow Creation**: Easily define and create Power Automate flows in JSON format.
- **Package Creation**: Easily create a legacy package that could import to Power Automate Platform
- **Customization**: Tailor your flows with dynamic parameters and custom logic.
- **Compatibility**: Seamless integration with existing Power Automate infrastructure.

## Installation

To install PyPowerAutomate, run the following command in your terminal:

```bash
pip install PyPowerAutomate
```

## Quick Start

Here's a simple example to get you started:

```python
from pypowerautomate.flow import Flow
from pypowerautomate.triggers import ManualTrigger
from pypowerautomate.actions import InitVariableAction,IncrementVariableAction,VariableTypes
from pypowerautomate.package import Package

flow = Flow()

flow.set_trigger(ManualTrigger("Button"))

flow.add_top_action(InitVariableAction("action1","a",VariableTypes.integer,1))
flow.append_action(IncrementVariableAction("action2","a",2))

package = Package("incremental_test",flow)
package.export_zipfile()
```

This example creates manual trigger and 2 actions. Then export the flow as lagacy package(zip file).
You can import the flow by uploading `incremental_test.zip` to Power Automate.

## Supported Triggers

- Manual Trigger
- Schedule Trigger

## Supported Build-in Actions

- Variable
- Conditionals
- Loops
- Data Operetions
- Time
- HTTP (requires Premium subscription)

## Supported Connectors

Currently, PyPowerAutomate supports following connectors.

- [Power Automate Management](https://powerautomate.microsoft.com/en-us/connectors/details/shared_flowmanagement/power-automate-management/)
- [Approvals](https://powerautomate.microsoft.com/en-us/connectors/details/shared_approvals/approvals/)
- [Office 365 Outlook](https://powerautomate.microsoft.com/en-us/connectors/details/shared_office365/office-365-outlook/)
- [SharePoint](https://powerautomate.microsoft.com/en-us/connectors/details/shared_sharepointonline/sharepoint/)
- [Dropbox](https://powerautomate.microsoft.com/en-us/connectors/details/shared_dropbox/dropbox/)
- [Teams](https://powerautomate.microsoft.com/en-us/connectors/details/shared_teams/microsoft-teams/)

## Documentation

[Documentation of PyPowerAutomate](https://ntt-security-japan.github.io/PyPowerAutomate/)

## Contributing

Thank you for considering contributing to this project! We welcome all contributions, from minor fixes to major features. To ensure effective and smooth collaboration, please follow these guidelines:

### Contributing Code

1. Check and Open Issues: Before contributing, please check if there are existing issues on GitHub related to your problem or suggestion. If not, open a new one and share the details.

2. Pull Requests: If you want to make changes, first fork the repository, create a branch for your topic, and then submit a pull request. In your pull request, clearly explain what changes you made and why.

3. Code Review: The project maintainers will review your pull request. If there are any comments, please respond to them actively.

### Code of Conduct

We aim to provide all contributors and maintainers with a safe and positive experience. Therefore, we ask you to follow this code of conduct, which is based on the Contributor Covenant:

- Respect Each Other: Treat everyone working on the project respectfully, regardless of background.

- Promote Inclusivity: Actively promote inclusivity and welcome diverse perspectives.

- Maintain a Harassment-Free Environment: Avoid any behavior seen as harassment and maintain a harassment-free environment.

## License

PyPowerAutomate is licensed under the BSD-3-clause license. See [LICENSE](https://github.com/NTT-Security-Japan/PyPowerAutomate/LICENSE) for more details.

---

Happy Automating! 🚀

---

27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "PyPowerAutomate"
version = "1.0"
authors = [
{ name="Tomoaki Tani" },
]
description = "Library to generate Power Automate Flow, Actions, and Legacy packages"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
]
license = {file = "LICENSE"}
keywords = ["PowerAutomate", "RPA"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
]

[project.urls]
Homepage = "https://github.com/NTT-Security-Japan/PyPowerAutomate"
Issues = "https://github.com/NTT-Security-Japan/PyPowerAutomate/issues"
Blog = "https://jp.security.ntt/tech_blog"
3 changes: 3 additions & 0 deletions src/pypowerautomate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
.. include:: ../../README.md
"""
Loading

0 comments on commit a8bf1c1

Please sign in to comment.