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
6 changes: 4 additions & 2 deletions .github/workflows/cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
const labels = issue.labels.map(label => label.name);
console.log(`Labels: ${labels}`);

const branches = labels.filter(label => label.startsWith('backport '))
.map(label => label.substr(9));
const branches = labels.filter(label => label.startsWith('cherry-pick/'))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer backport over cherry-pick, as it's clearer what's supposed to happen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm collecting the current status of things, and I will explain it at guacsec/trustify#1472 what we have now. And we can certainly customize things like "cherry-pick" vs "backport".

.map(label => label.substr(12));
console.log(`Branches: ${branches}`);

return branches
Expand Down Expand Up @@ -54,4 +54,6 @@ jobs:
uses: korthout/backport-action@v3
with:
github_token: ${{ steps.get_workflow_token.outputs.token }}
label_pattern: >-
^cherry-pick\/([^ ]+)$
pull_title: '${pull_title} [Backport ${target_branch}]'
9 changes: 9 additions & 0 deletions cmd/verify-pr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ struct PullRequestEvent {
}

fn main() -> error::Result<()> {
let result = verify_pr();
match &result {
Ok(_) => {}
Err(error) => println!("{error}"),
};
result
}

fn verify_pr() -> error::Result<()> {
let gh_context = GitHubVariables::from_env()?;

// Parse the event
Expand Down
85 changes: 85 additions & 0 deletions create-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Create Release
description: Create a release in a project
inputs:
github_token:
description: 'GitHub token'
required: true
version:
description: 'Semantic version of the release (eg. v1.2.3 or v1.2.3-alpha.2)'
required: true
prev_version:
description: 'Semantic version of the previous release (eg. v1.2.2 or v1.2.3-alpha.1)'
required: false
default: ''
repository:
description: 'The repository where the release should be created'
required: false
default: ${{ github.repository }}
ref:
description: 'The branch or SHA for the release (defaults to main)'
required: false
default: ${{ github.ref }}
is_prerelease:
description: 'Is this a pre-release?'
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Verify tag is semver
shell: bash
run: |
set -x
if [[ ! "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
echo "This is not a semver compliant tag"
echo "Exiting"
exit 1
fi

if [[ "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_prerelease=false" >> $GITHUB_OUTPUT
else
echo "is_prerelease=true" >> $GITHUB_OUTPUT
fi

if [[ "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "is_dotzero=true" >> $GITHUB_OUTPUT
else
echo "is_dotzero=false" >> $GITHUB_OUTPUT
fi

XY_VERSION=$(echo ${{ inputs.version }} | awk -F. '{print substr($1,2)"."$2}')
echo "xy_version=${XY_VERSION}" >> $GITHUB_OUTPUT
id: check_tag

- name: Checkout code
uses: actions/checkout@v4

- name: Generate Changelog
uses: ./.github/workflows/generate-changelog.yml
with:
version: ${{ github.event.inputs.version }}
prev_version: ${{ github.event.inputs.prev_version }}
repository: ${{ github.event.inputs.repository }}
ref: ${{ github.event.inputs.ref }}
github_token: ${{ inputs.github_token }}

- name: Download Changelog
uses: actions/download-artifact@v4
with:
name: changelog-artifact
path: .


- uses: ncipollo/release-action@main
with:
owner: ${{ github.repository_owner }}
repo: ${{ inputs.repository }}
tag: ${{ inputs.version }}
commit: ${{ github.sha }}
bodyFile: release.md
draft: false
prerelease: ${{ inputs.is_prerelease }}
skipIfReleaseExists: true
token: ${{ inputs.github_token }}
4 changes: 3 additions & 1 deletion pkg/pr/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, PartialEq, thiserror::Error)]
pub enum Error {
#[error("Invalid prefix (title {title:?}, emoji {emoji:?})")]
#[error(
"Invalid prefix (title: {title}, emoji: {emoji:#?}).\nValid prefixes are:\n:sparkles:\n:bug:\n:book:\n:seedling:\n:warning:\n:ghost:\n"
)]
InvalidTitle {
title: String,
emoji: Option<String>,
Expand Down
Loading