-
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
Showing
13 changed files
with
496 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 @@ | ||
* @pavelzw |
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,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
groups: | ||
dependencies: | ||
patterns: | ||
- "*" |
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,26 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- ignore for release | ||
categories: | ||
- title: 💥 Breaking changes | ||
labels: | ||
- breaking | ||
- title: ✨ New features | ||
labels: | ||
- enhancement | ||
- title: 👷🏻 CI | ||
labels: | ||
- ci | ||
- title: 🐛 Bug fixes | ||
labels: | ||
- bug | ||
- title: 📝 Documentation | ||
labels: | ||
- documentation | ||
- title: ⬆️ Dependency updates | ||
labels: | ||
- dependencies | ||
- title: 🤷🏻 Other changes | ||
labels: | ||
- "*" |
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,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
version="${TAG_NAME}" | ||
major="${version%%.*}" # see https://linuxjournal.com/article/8919 for an explanation of this bash magic | ||
|
||
git tag -d "${major}" | ||
local_delete=$? | ||
if [ $local_delete -eq 0 ]; then | ||
echo "Deleted local tag ${major}." | ||
echo "Deleted local tag \`${major}\`." >> "$GITHUB_STEP_SUMMARY" | ||
else | ||
echo "No local tag ${major} to delete." | ||
echo "No local tag \`${major}\` to delete." >> "$GITHUB_STEP_SUMMARY" | ||
fi | ||
git tag "${major}" | ||
|
||
git push -d origin "${major}" | ||
remote_delete=$? | ||
if [ $remote_delete -eq 0 ]; then | ||
echo "Deleted remote tag ${major}." | ||
echo "Deleted remote tag \`${major}\`." >> "$GITHUB_STEP_SUMMARY" | ||
else | ||
echo "No remote tag ${major} to delete." | ||
echo "No remote tag \`${major}\` to delete." >> "$GITHUB_STEP_SUMMARY" | ||
fi | ||
git push origin "${major}" | ||
push_worked=$? | ||
if [ $push_worked -ne 0 ]; then | ||
echo "Failed to push ${major} tag to remote." | ||
echo "Failed to push \`${major}\` tag to remote." >> "$GITHUB_STEP_SUMMARY" | ||
exit 1 | ||
fi | ||
|
||
if [ $remote_delete -eq 0 ]; then | ||
echo "Result: moved ${major} -> ${version} tag on remote." | ||
echo "Result: moved \`${major}\` -> \`${version}\` tag on remote." >> "$GITHUB_STEP_SUMMARY" | ||
else | ||
echo "Result: created ${major} -> ${version} tag on remote." | ||
echo "Result: created \`${major}\` -> \`${version}\` tag on remote." >> "$GITHUB_STEP_SUMMARY" | ||
fi |
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,36 @@ | ||
name: Bump versions | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 6 * * *" | ||
|
||
jobs: | ||
bump: | ||
name: Bump ${{ matrix.tool }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- tool: rattler-build | ||
repo: prefix-dev/rattler-build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Bump versions | ||
id: bump | ||
run: | | ||
set -exuo pipefail | ||
new_version="$(gh repo view --json latestRelease ${{ matrix.repo }} | jq -r '.latestRelease.tagName')" | ||
echo "new-version=$new_version" >> "$GITHUB_OUTPUT" | ||
yq -i ".inputs.${{ matrix.tool }}-version.default = \"$new_version\"" action.yml | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 | ||
with: | ||
title: Bump ${{ matrix.tool }} to ${{ steps.bump.outputs.new-version }} | ||
delete-branch: true | ||
commit-message: Bump ${{ matrix.tool }} version to ${{ steps.bump.outputs.new-version }} | ||
branch: bump-${{ matrix.tool }}-${{ steps.bump.outputs.new-version }} | ||
labels: dependencies,breaking | ||
body: | | ||
- [ ] Update version in [project.toml](https://github.com/prefix-dev/rattler-build-action/blob/bump-${{ matrix.tool }}-${{ steps.bump.outputs.new-version }}/project.toml) |
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,32 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: main | ||
permissions: | ||
contents: write | ||
|
||
# To release a new version, update the version in `project.toml` and push to main. | ||
# This will create a draft release with the changelog and push a 'vx' tag that points to the new release as well as 'vx.y.z'. | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: quantco/ui-actions/version-metadata@v1 | ||
id: version-metadata | ||
with: | ||
file: ./project.toml | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
version-extraction-override: 'regex:version = "(.*)"' | ||
- run: .github/scripts/release.sh | ||
if: steps.version-metadata.outputs.changed == 'true' | ||
env: | ||
TAG_NAME: v${{ steps.version-metadata.outputs.newVersion }} | ||
- name: Create release | ||
if: steps.version-metadata.outputs.changed == 'true' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
generate_release_notes: true | ||
tag_name: v${{ steps.version-metadata.outputs.newVersion }} |
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,59 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
bump: | ||
name: Test action | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
recipe: | ||
- polarify | ||
- test-package | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
- macos-14 | ||
- windows-latest | ||
rattler-build-version: | ||
- '' # default | ||
- latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./ | ||
with: | ||
recipe-path: test/${{ matrix.recipe }}/recipe.yaml | ||
artifact-name: package-${{ matrix.recipe }}-${{ matrix.os }}-${{ matrix.rattler-build-version }} | ||
|
||
check-readme: | ||
name: Check versions in README.md | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check rattler-build-action version mentions | ||
run: | | ||
project_version="$(yq '.version' project.toml)" | ||
count_expected=5 | ||
count_actual="$(grep -c "prefix-dev/rattler-build-action@v${project_version}" README.md || true)" | ||
if [ "$count_actual" -ne "$count_expected" ]; then | ||
echo "::error file=README.md::Expected $count_expected mentions of \`rattler-build-action@v$project_version\` in README.md, but found $count_actual." | ||
exit 1 | ||
fi | ||
- name: Check rattler-build version mentions | ||
run: | | ||
rattler_build_version="$(yq '.inputs.rattler-build-version' action.yml)" | ||
count_expected=1 | ||
count_actual="$(grep -c "rattler-build-version" README.md | grep "$rattler_build_version" || true)" | ||
if [ "$count_actual" -ne "$count_expected" ]; then | ||
echo "::error file=README.md::Expected $count_expected mentions of \`rattler-build\` version \`0.6.0\` in README.md, but found $count_actual." | ||
exit 1 | ||
fi |
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,28 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2024, Pavel Zwerschke | ||
|
||
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. |
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 |
---|---|---|
@@ -1 +1,134 @@ | ||
# rattler-build-action | ||
# rattler-build-action 📦🐍 | ||
|
||
`rattler-build-action` is a GitHub Action for building conda packages using [rattler-build](https://github.com/prefix-dev/rattler-build). | ||
|
||
## Usage | ||
|
||
Create `.github/workflows/package.yml` in your repository. Here's a quick template: | ||
|
||
```yml | ||
name: Package | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: Build package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build conda package | ||
uses: prefix-dev/[email protected] | ||
``` | ||
> [!WARNING] | ||
> Since rattler-build is still experimental and the API can change in minor versions, please pin this action to its minor version, i.e., `prefix-dev/[email protected]`. | ||
> [!TIP] | ||
> Please make sure to have private repositories enabled for dependabot, otherwise dependabot will fail silently for your repository. | ||
> | ||
> ```yml | ||
> version: 2 | ||
> updates: | ||
> - package-ecosystem: github-actions | ||
> directory: / | ||
> schedule: | ||
> interval: monthly | ||
> groups: | ||
> gh-actions: | ||
> patterns: | ||
> - "*" | ||
> ``` | ||
|
||
This action will build the conda recipe in `conda.recipe/recipe.yaml` and upload the built packages as a build artifact. | ||
|
||
## Customizations | ||
|
||
- `rattler-build-version`: Define the version of rattler-build. Pins to the latest version that is available when releasing. | ||
- `recipe-path`: Path to the rattler recipe. Defaults to `conda.recipe/recipe.yaml`. | ||
- `upload-artifact`: Decide whether to upload the built packages as a build artifact. | ||
- `build-args`: Additional arguments to pass to `rattler-build build`. | ||
- `artifact-name`: Name of the artifact that is uploaded after build. If running `rattler-build-action` multiple times in a matrix, you need a distinct name for each workflow. | ||
|
||
### `rattler-build-version` | ||
|
||
`rattler-build-version` is strictly pinned to the latest version of `rattler-build` that is available when releasing a new version of `rattler-build-action`. | ||
This is to ensure that no breakages occur if a new version of `rattler-build` is released. | ||
|
||
You can use dependabot to automatically update the version of `prefix-dev/rattler-build-action` which will also update the version of `rattler-build` to the latest version. | ||
|
||
## Examples | ||
|
||
### Build for multiple targets using matrix | ||
|
||
```yml | ||
jobs: | ||
build: | ||
name: Build package | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target-platform: linux-64 | ||
- os: ubuntu-latest | ||
target-platform: linux-aarch64 | ||
- os: windows-latest | ||
target-platform: win-64 | ||
- os: macos-latest | ||
target-platform: osx-64 | ||
- os: macos-14 | ||
target-platform: osx-arm64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build conda package | ||
uses: prefix-dev/[email protected] | ||
with: | ||
# needs to be unique for each matrix entry | ||
artifact-name: package-${{ matrix.target-platform }} | ||
build-args: --target-platform ${{ matrix.target-platform }}${{ matrix.target-platform == 'linux-aarch64' && ' --no-test' || '' }} | ||
``` | ||
|
||
### Upload to quetz | ||
|
||
```yml | ||
jobs: | ||
build: | ||
name: Build package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build conda package | ||
uses: prefix-dev/[email protected] | ||
- run: | | ||
for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do | ||
echo "Uploading ${pkg}" | ||
rattler-build upload quetz "${pkg}" | ||
done | ||
env: | ||
QUETZ_SERVER_URL: https://my.quetz.server | ||
QUETZ_API_KEY: ${{ secrets.QUETZ_API_KEY }} | ||
QUETZ_CHANNEL: my-channel | ||
``` | ||
|
||
### Use private channel | ||
|
||
You can use a private channel while building your conda package by setting the `RATTLER_AUTH_FILE` environment variable. | ||
As of now, `rattler-build` does not support a `login` command [prefix-dev/rattler-build#334](https://github.com/prefix-dev/rattler-build/issues/334), so you need to create the `RATTLER_AUTH_FILE` manually. | ||
|
||
```yml | ||
jobs: | ||
build: | ||
name: Build package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Authenticate with private channel | ||
run: | | ||
RATTLER_AUTH_FILE=${{ runner.temp }}/credentials.json | ||
echo '{"my.quetz.server": {"CondaToken": "${{ secrets.QUETZ_API_KEY }}"}}' > "$RATTLER_AUTH_FILE" | ||
echo "RATTLER_AUTH_FILE=$RATTLER_AUTH_FILE" >> "$GITHUB_ENV" | ||
- name: Build conda package | ||
uses: prefix-dev/[email protected] | ||
with: | ||
build-args: -c conda-forge -c https://my.quetz.server/get/my-channel | ||
``` |
Oops, something went wrong.