diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index aa74ade..bf87206 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -1,62 +1,29 @@ -name: release-please +name: Release Please on: - push: - branches: - - main + workflow_call: + secrets: + application-id: + required: true + private-key: + required: true permissions: contents: write pull-requests: write -concurrency: - group: release-please - cancel-in-progress: false - jobs: - setup-release-context: - runs-on: ubuntu-latest - outputs: - packages: ${{ steps.check-files.outputs.packages }} - prev_sha: ${{ steps.check-files.outputs.prev_sha }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Get list of workflows with changes - id: check-files - run: | - # Get list of workflows - workflow_list=($(basename -a -s .yml $(find .github/workflows/ -type f -print | xargs -I{} grep -l "workflow_call:$" {}))) - # Get list of workflows to release - workflow_with_changes=$(printf "/%s[./]\n" ${workflow_list[@]} | xargs -I{} sh -c "git diff --name-only ${{ github.sha }} ${{ github.sha }}^ | grep -om1 -e '{}' || true" | tr -d /.) - releases_with_changes=$(printf "^%s[./]\n" ${workflow_list[@]} | xargs -I{} sh -c "git diff --name-only ${{ github.sha }} ${{ github.sha }}^ | grep -om1 -e '{}' || true" | tr -d /.) - # Set list of workflows to release - echo "packages=$(jq -cn --args '$ARGS.positional' -- ${workflow_with_changes[@]} ${releases_with_changes[@]})" >> "$GITHUB_OUTPUT" - echo "prev_sha=$(git rev-parse ${{ github.sha }}^)" >> "$GITHUB_OUTPUT" - shell: bash - release-please: - needs: setup-release-context - if: ${{ needs.setup-release-context.outputs.packages != '[]' }} runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - package: ${{ fromJSON(needs.setup-release-context.outputs.packages) }} steps: - - uses: googleapis/release-please-action@v3 - id: release + - name: Get Token + id: get_token + uses: peter-murray/workflow-application-token-action@v3 + with: + application_id: "${{ secrets.release-please-application-id }}" + application_private_key: ${{ secrets.release-please-private-key }} + organization: ${{ github.repository_owner }} + - name: Run release-please + uses: googleapis/release-please-action@v4 with: - default-branch: main - token: ${{ secrets.RELEASE_PLEASE_TOKEN }} - release-type: simple - package-name: ${{ matrix.package }} - version-file: ${{ matrix.package }}/version.txt - changelog-path: ${{ matrix.package }}/CHANGELOG.md - last-release-sha: ${{ needs.setup-release-context.outputs.prev_sha }} - labels: ${{ matrix.package }} - bump-patch-for-minor-pre-major: true - bump-minor-pre-major: true - monorepo-tags: true - release-as: "" + token: ${{ steps.get_token.outputs.token }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..aa74ade --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: release-please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +concurrency: + group: release-please + cancel-in-progress: false + +jobs: + setup-release-context: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.check-files.outputs.packages }} + prev_sha: ${{ steps.check-files.outputs.prev_sha }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Get list of workflows with changes + id: check-files + run: | + # Get list of workflows + workflow_list=($(basename -a -s .yml $(find .github/workflows/ -type f -print | xargs -I{} grep -l "workflow_call:$" {}))) + # Get list of workflows to release + workflow_with_changes=$(printf "/%s[./]\n" ${workflow_list[@]} | xargs -I{} sh -c "git diff --name-only ${{ github.sha }} ${{ github.sha }}^ | grep -om1 -e '{}' || true" | tr -d /.) + releases_with_changes=$(printf "^%s[./]\n" ${workflow_list[@]} | xargs -I{} sh -c "git diff --name-only ${{ github.sha }} ${{ github.sha }}^ | grep -om1 -e '{}' || true" | tr -d /.) + # Set list of workflows to release + echo "packages=$(jq -cn --args '$ARGS.positional' -- ${workflow_with_changes[@]} ${releases_with_changes[@]})" >> "$GITHUB_OUTPUT" + echo "prev_sha=$(git rev-parse ${{ github.sha }}^)" >> "$GITHUB_OUTPUT" + shell: bash + + release-please: + needs: setup-release-context + if: ${{ needs.setup-release-context.outputs.packages != '[]' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: ${{ fromJSON(needs.setup-release-context.outputs.packages) }} + steps: + - uses: googleapis/release-please-action@v3 + id: release + with: + default-branch: main + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + release-type: simple + package-name: ${{ matrix.package }} + version-file: ${{ matrix.package }}/version.txt + changelog-path: ${{ matrix.package }}/CHANGELOG.md + last-release-sha: ${{ needs.setup-release-context.outputs.prev_sha }} + labels: ${{ matrix.package }} + bump-patch-for-minor-pre-major: true + bump-minor-pre-major: true + monorepo-tags: true + release-as: "" diff --git a/README.md b/README.md index e7545d9..37fa946 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,8 @@ This repository contains a reusable workflow for iExec. It is a monorepo that co ## Components -### [Build Docker Image](./workflows/build-docker) +### [Build Docker Image](./docker-build) This workflow builds a Docker image from a Dockerfile. It is a reusable workflow that can be used in other workflows. -#### Inputs - -- `dockerhub-username`: The username of the Docker Hub account where the image will be pushed. -- `dockerhub-pat`: The password of the Docker Hub account where the image will be pushed. -- `dockerfile`: The path to the Dockerfile that will be used to build the image. -- `image-name`: The name of the image that will be built. \ No newline at end of file +### [Release Please](./release-please) +This workflow uses the [release-please-action](https://github.com/googleapis/release-please-action) to automate the release of a project. \ No newline at end of file diff --git a/docker-build/README.md b/docker-build/README.md index 392ddea..2b77c60 100644 --- a/docker-build/README.md +++ b/docker-build/README.md @@ -1 +1,33 @@ -# Docker build \ No newline at end of file +# Docker build + +## Inputs + +### `dockerfile` + +**Required** The path to the Dockerfile to build. + +### `tag` + +**Required** The tag to apply to the built image. + +## Secrets + +### `dockerhub_username` + +**Required** The username to use to log in to Docker Hub. + +### `dockerhub_pat` + +**Required** The personal access token to use to log in to Docker Hub. + +## Example usage + +```yaml +uses: iExecBlockchainComputing/github-actions-workflows/docker-build@docker-build-v1.1.1 +with: + dockerfile: 'Dockerfile' + tag: 'my-image:latest' +secrets: + dockerhub_username: ${{ secrets.dockerhub_username }} + dockerhub_pat: ${{ secrets.dokerhub_pat }} +``` diff --git a/release-please/CHANGELOG.md b/release-please/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/release-please/README.md b/release-please/README.md new file mode 100644 index 0000000..ee7da28 --- /dev/null +++ b/release-please/README.md @@ -0,0 +1,23 @@ +# Release please reusable workflows + +This is the reusable workflow for release any project. + +## Secrets + +### application_id + +**Required** The application id to use to log app in to GitHub. + +### private_key + +**Required** The private key to use to log app in to GitHub. + + +## Example usage + +```yaml +uses: iExecBlockchainComputing/github-actions-workflows/release-please@release-please-v1.0.0 +secrets: + application_id: ${{ secrets.application_id }} + private_key: ${{ secrets.private_key }} +``` \ No newline at end of file diff --git a/release-please/version.txt b/release-please/version.txt new file mode 100644 index 0000000..e69de29