Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 17 additions & 50 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -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 }}
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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: ""
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
### [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.
34 changes: 33 additions & 1 deletion docker-build/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# Docker build
# 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/[email protected]
with:
dockerfile: 'Dockerfile'
tag: 'my-image:latest'
secrets:
dockerhub_username: ${{ secrets.dockerhub_username }}
dockerhub_pat: ${{ secrets.dokerhub_pat }}
```
Empty file added release-please/CHANGELOG.md
Empty file.
23 changes: 23 additions & 0 deletions release-please/README.md
Original file line number Diff line number Diff line change
@@ -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/[email protected]
secrets:
application_id: ${{ secrets.application_id }}
private_key: ${{ secrets.private_key }}
```
Empty file added release-please/version.txt
Empty file.