Skip to content

Commit 479771d

Browse files
committed
feat(release-please): add release please
1 parent 052644d commit 479771d

File tree

7 files changed

+138
-58
lines changed

7 files changed

+138
-58
lines changed
Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,29 @@
1-
name: release-please
1+
name: Release Please
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_call:
5+
secrets:
6+
application-id:
7+
required: true
8+
private-key:
9+
required: true
710

811
permissions:
912
contents: write
1013
pull-requests: write
1114

12-
concurrency:
13-
group: release-please
14-
cancel-in-progress: false
15-
1615
jobs:
17-
setup-release-context:
18-
runs-on: ubuntu-latest
19-
outputs:
20-
packages: ${{ steps.check-files.outputs.packages }}
21-
prev_sha: ${{ steps.check-files.outputs.prev_sha }}
22-
steps:
23-
- uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 2
26-
- name: Get list of workflows with changes
27-
id: check-files
28-
run: |
29-
# Get list of workflows
30-
workflow_list=($(basename -a -s .yml $(find .github/workflows/ -type f -print | xargs -I{} grep -l "workflow_call:$" {})))
31-
# Get list of workflows to release
32-
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 /.)
33-
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 /.)
34-
# Set list of workflows to release
35-
echo "packages=$(jq -cn --args '$ARGS.positional' -- ${workflow_with_changes[@]} ${releases_with_changes[@]})" >> "$GITHUB_OUTPUT"
36-
echo "prev_sha=$(git rev-parse ${{ github.sha }}^)" >> "$GITHUB_OUTPUT"
37-
shell: bash
38-
3916
release-please:
40-
needs: setup-release-context
41-
if: ${{ needs.setup-release-context.outputs.packages != '[]' }}
4217
runs-on: ubuntu-latest
43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
package: ${{ fromJSON(needs.setup-release-context.outputs.packages) }}
4718
steps:
48-
- uses: googleapis/release-please-action@v3
49-
id: release
19+
- name: Get Token
20+
id: get_token
21+
uses: peter-murray/workflow-application-token-action@v3
22+
with:
23+
application_id: "${{ secrets.release-please-application-id }}"
24+
application_private_key: ${{ secrets.release-please-private-key }}
25+
organization: ${{ github.repository_owner }}
26+
- name: Run release-please
27+
uses: googleapis/release-please-action@v4
5028
with:
51-
default-branch: main
52-
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
53-
release-type: simple
54-
package-name: ${{ matrix.package }}
55-
version-file: ${{ matrix.package }}/version.txt
56-
changelog-path: ${{ matrix.package }}/CHANGELOG.md
57-
last-release-sha: ${{ needs.setup-release-context.outputs.prev_sha }}
58-
labels: ${{ matrix.package }}
59-
bump-patch-for-minor-pre-major: true
60-
bump-minor-pre-major: true
61-
monorepo-tags: true
62-
release-as: ""
29+
token: ${{ steps.get_token.outputs.token }}

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
concurrency:
13+
group: release-please
14+
cancel-in-progress: false
15+
16+
jobs:
17+
setup-release-context:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
packages: ${{ steps.check-files.outputs.packages }}
21+
prev_sha: ${{ steps.check-files.outputs.prev_sha }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 2
26+
- name: Get list of workflows with changes
27+
id: check-files
28+
run: |
29+
# Get list of workflows
30+
workflow_list=($(basename -a -s .yml $(find .github/workflows/ -type f -print | xargs -I{} grep -l "workflow_call:$" {})))
31+
# Get list of workflows to release
32+
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 /.)
33+
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 /.)
34+
# Set list of workflows to release
35+
echo "packages=$(jq -cn --args '$ARGS.positional' -- ${workflow_with_changes[@]} ${releases_with_changes[@]})" >> "$GITHUB_OUTPUT"
36+
echo "prev_sha=$(git rev-parse ${{ github.sha }}^)" >> "$GITHUB_OUTPUT"
37+
shell: bash
38+
39+
release-please:
40+
needs: setup-release-context
41+
if: ${{ needs.setup-release-context.outputs.packages != '[]' }}
42+
runs-on: ubuntu-latest
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
package: ${{ fromJSON(needs.setup-release-context.outputs.packages) }}
47+
steps:
48+
- uses: googleapis/release-please-action@v3
49+
id: release
50+
with:
51+
default-branch: main
52+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
53+
release-type: simple
54+
package-name: ${{ matrix.package }}
55+
version-file: ${{ matrix.package }}/version.txt
56+
changelog-path: ${{ matrix.package }}/CHANGELOG.md
57+
last-release-sha: ${{ needs.setup-release-context.outputs.prev_sha }}
58+
labels: ${{ matrix.package }}
59+
bump-patch-for-minor-pre-major: true
60+
bump-minor-pre-major: true
61+
monorepo-tags: true
62+
release-as: ""

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ This repository contains a reusable workflow for iExec. It is a monorepo that co
44

55
## Components
66

7-
### [Build Docker Image](./workflows/build-docker)
7+
### [Build Docker Image](./docker-build)
88
This workflow builds a Docker image from a Dockerfile. It is a reusable workflow that can be used in other workflows.
99

10-
#### Inputs
11-
12-
- `dockerhub-username`: The username of the Docker Hub account where the image will be pushed.
13-
- `dockerhub-pat`: The password of the Docker Hub account where the image will be pushed.
14-
- `dockerfile`: The path to the Dockerfile that will be used to build the image.
15-
- `image-name`: The name of the image that will be built.
10+
### [Release Please](./release-please)
11+
This workflow uses the [release-please-action](https://github.com/googleapis/release-please-action) to automate the release of a project.

docker-build/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# Docker build
1+
# Docker build
2+
3+
## Inputs
4+
5+
### `dockerfile`
6+
7+
**Required** The path to the Dockerfile to build.
8+
9+
### `tag`
10+
11+
**Required** The tag to apply to the built image.
12+
13+
## Secrets
14+
15+
### `dockerhub_username`
16+
17+
**Required** The username to use to log in to Docker Hub.
18+
19+
### `dockerhub_pat`
20+
21+
**Required** The personal access token to use to log in to Docker Hub.
22+
23+
## Example usage
24+
25+
```yaml
26+
uses: iExecBlockchainComputing/github-actions-workflows/[email protected]
27+
with:
28+
dockerfile: 'Dockerfile'
29+
tag: 'my-image:latest'
30+
secrets:
31+
dockerhub_username: ${{ secrets.dockerhub_username }}
32+
dockerhub_pat: ${{ secrets.dokerhub_pat }}
33+
```

release-please/CHANGELOG.md

Whitespace-only changes.

release-please/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Release please reusable workflows
2+
3+
This is the reusable workflow for release any project.
4+
5+
## Secrets
6+
7+
### application_id
8+
9+
**Required** The application id to use to log app in to GitHub.
10+
11+
### private_key
12+
13+
**Required** The private key to use to log app in to GitHub.
14+
15+
16+
## Example usage
17+
18+
```yaml
19+
uses: iExecBlockchainComputing/github-actions-workflows/[email protected]
20+
secrets:
21+
application_id: ${{ secrets.application_id }}
22+
private_key: ${{ secrets.private_key }}
23+
```

release-please/version.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)