-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ed4b83
commit 419d0bd
Showing
8 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "[lint] Commit is conventional" | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- edited | ||
- opened | ||
- ready_for_review | ||
- reopened | ||
- synchronize | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
pull-requests: write | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
uses: kolonialno/actions/.github/workflows/pr-conventional-commit.yml@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
name: "[release] Please" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- ci/test-release-please** | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: google-github-actions/release-please-action@v4 | ||
id: release | ||
with: | ||
# When you use the repository's GITHUB_TOKEN to perform tasks, events such as 'on.release' | ||
# use in the Upload artifacts workflow wont be triggered. | ||
# This prevents you from accidentally creating recursive workflow runs. | ||
# We needed to use either a PAT og a GitHub App. | ||
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow | ||
token: ${{ secrets.TIENDABOT_ACCESS_TOKEN }} | ||
config-file: release-please-config.json | ||
manifest-file: .release-please-manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
--- | ||
name: "[release] Upload artifacts" | ||
|
||
on: | ||
# Manually triggering this from main branch | ||
# will upload artifacts to current release. | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
type: string | ||
description: Tag to checkout. View tags at https://github.com/kolonialno/velo/tags | ||
default: "" | ||
push: | ||
branches: | ||
- release-test-** | ||
release: | ||
types: | ||
# Trigger on creation of a draft is not possible | ||
# https://github.com/orgs/community/discussions/7118 | ||
# ref https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release | ||
# This will trigger when a pre-release is created, but not when published. | ||
- prereleased | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
name: Tag on commit | ||
outputs: | ||
upload: ${{ steps.tag.outputs.upload }} | ||
tag: ${{ steps.tag.outputs.tag }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag == '' }} | ||
|
||
- name: Checkout tag (workflow_dispatch) | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag != '' }} | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- name: Setup Python | ||
uses: kolonialno/actions/setup-python@setup-python-2.2.0 | ||
id: setup | ||
|
||
# Only upload if current commit has a tag that match the version in | ||
# Pyproject. This will only be the case for a velo tag that has format | ||
# x.y.z | ||
# The other releases have component name prefixed. Eaxmple: component-x.y.z. | ||
- name: Verify semVer tag on commit | ||
id: tag | ||
run: | | ||
set -ex | ||
if [ "${{ github.event.inputs.tag }}" == '' ]; then | ||
tag=$(git tag --points-at ${{ github.sha }}) | ||
echo tag=$tag | ||
echo "tag=$tag" >> $GITHUB_OUTPUT; | ||
project_version=$(poetry version -s) | ||
echo project_version=$project_version | ||
if [ "$tag" == "$project_version" ]; then | ||
echo "upload=true" >> $GITHUB_OUTPUT; | ||
else | ||
echo "upload=false" >> $GITHUB_OUTPUT; | ||
fi | ||
else | ||
echo "upload=true" >> $GITHUB_OUTPUT; | ||
fi | ||
build-velo-binary: | ||
name: Build Velo binary (PEX) for ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
needs: tag | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
artifact_name: velo | ||
asset_name: velo-linux-amd64 | ||
- os: macos-latest | ||
artifact_name: velo | ||
asset_name: velo-macos-amd64 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag == '' }} | ||
|
||
- name: Checkout tag (workflow_dispatch) | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag != '' }} | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- name: Setup Python | ||
uses: kolonialno/actions/setup-python@setup-python-2.2.0 | ||
id: setup | ||
|
||
- name: Output Pyproject version | ||
shell: bash | ||
id: pyproject | ||
# The '+' delimiter makes it a "local version" in PEP 440 | ||
run: | | ||
set -ex | ||
if [ "${{ github.ref }}" == 'refs/heads/main' ] || [ "${{ github.ref }}" == 'refs/tags/${{ needs.tag.outputs.tag }}' ]; then | ||
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT | ||
echo "pep440-version=$(poetry version -s)" >> $GITHUB_OUTPUT | ||
else | ||
echo "version=$(poetry version -s)-${{ github.sha }}" >> $GITHUB_OUTPUT | ||
echo "pep440-version=$(poetry version -s)+${{ github.sha }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Build Pex binary ${{ matrix.asset_name }} | ||
uses: ./.github/actions/build-pex-binary | ||
id: pex | ||
with: | ||
version: ${{ steps.pyproject.outputs.pep440-version }} | ||
pex_entrypoint: velo.cli | ||
filename: ${{ matrix.asset_name }} | ||
architecture: ${{ matrix.os }} | ||
|
||
# Cant upload artifacts to draft release | ||
- name: Upload Release Artifact | ||
if: ${{ needs.tag.outputs.upload == 'true' }} | ||
run: gh release upload ${{ steps.pyproject.outputs.version }} ${{ steps.pex.outputs.path}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
python_package: | ||
runs-on: ubuntu-latest | ||
name: Python package | ||
needs: tag | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag == '' }} | ||
|
||
- name: Checkout tag (workflow_dispatch) | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag != '' }} | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- name: Setup Python | ||
uses: kolonialno/actions/setup-python@setup-python-2.2.0 | ||
|
||
- name: Poetry build | ||
run: | | ||
set -ex | ||
poetry version -s | ||
poetry build | ||
- name: Publish Velo Python package | ||
if: ${{ needs.tag.outputs.upload == 'true' }} | ||
run: | | ||
set -ex | ||
poetry publish -r nube-python --skip-existing --no-interaction --verbose | ||
build-and-publish-image: | ||
runs-on: ubuntu-latest | ||
name: Build and Publish Velo image | ||
needs: | ||
- tag | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag == '' }} | ||
|
||
- name: Checkout tag (workflow_dispatch) | ||
uses: actions/checkout@v4 | ||
if: ${{ github.event.inputs.tag != '' }} | ||
with: | ||
ref: ${{ github.event.inputs.tag }} | ||
|
||
- uses: kolonialno/actions/build-image@build-image-3.0.0 | ||
if: ${{ needs.tag.outputs.upload == 'true' }} | ||
with: | ||
image: velo | ||
version: ${{ needs.tag.outputs.tag }} | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
name: Publish | ||
needs: | ||
- python_package | ||
- build-velo-binary | ||
- build-and-publish-image | ||
- tag | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Publish pre-release | ||
if: ${{ needs.tag.outputs.upload == 'true' }} | ||
run: | | ||
set -ex | ||
gh release edit ${{ needs.tag.outputs.tag }} --prerelease=false --latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
velo: | ||
runs-on: ubuntu-latest | ||
name: Test pulling PEX from latest release | ||
if: ${{ needs.tag.outputs.upload == 'true' }} | ||
needs: | ||
- publish | ||
- tag | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- id: velo | ||
run: | | ||
set -ex | ||
echo "velo-version=$(gh api -H "Accept: application/vnd.github+json" /repos/kolonialno/velo/releases/latest | jq -r .tag_name)" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Install latest release | ||
- uses: ./.github/actions/setup-velo | ||
|
||
- run: | | ||
set -ex | ||
velo --version | ||
test "$(velo --version)" == "${{ steps.velo.outputs.velo-version }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
default_install_hook_types: [pre-commit, commit-msg] | ||
repos: | ||
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook | ||
rev: "v9.11.0" | ||
hooks: | ||
- id: commitlint | ||
stages: [commit-msg] | ||
additional_dependencies: ["@commitlint/config-conventional"] | ||
args: | ||
- "--config=commitlint.config.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "4.3.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# CONTRIBUTING | ||
|
||
## Set-up | ||
|
||
```shell | ||
pre-commit install | ||
poetry install | ||
``` | ||
|
||
## Release | ||
|
||
We use [release-please](https://github.com/googleapis/release-please) to automate release including semver version based on [conventional-commits](https://www.conventionalcommits.org/en/v1.0.0/). | ||
|
||
Manually create a release PR from main branch | ||
|
||
```bash | ||
release-please release-pr \ | ||
--token=$(gh auth token) \ | ||
--repo-url=kolonialno/troncos | ||
--dry-run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: ["@commitlint/config-conventional"], | ||
rules: { | ||
"footer-max-line-length": [0, "always"], // ignore rule | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", | ||
"bootstrap-sha": "3c032c809f68f677d12fdac5557351cde40bffd7", | ||
"include-v-in-tag": false, | ||
"separate-pull-requests": true, | ||
"prerelease": true, | ||
"packages": { | ||
".": { | ||
"component": "troncos", | ||
"bump-minor-pre-major": true, | ||
"include-component-in-tag": false, | ||
"release-type": "python" | ||
} | ||
} | ||
} |