Apache DataFusion SQL Query Engine
ci: Add target release version labels to merged PRs (#25776)
Nuno Faria51c2e044ee99
diff --git a/.github/workflows/release_version_labeler.yaml b/.github/workflows/release_version_labeler.yamlnew file mode 100644index 0000000000..d2ab0c6fc0--- /dev/null+++ b/.github/workflows/release_version_labeler.yaml@@ -0,0 +1,46 @@+# Licensed to the Apache Software Foundation (ASF) under one+# or more contributor license agreements. See the NOTICE file+# distributed with this work for additional information+# regarding copyright ownership. The ASF licenses this file+# to you under the Apache License, Version 2.0 (the+# "License"); you may not use this file except in compliance+# with the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing,+# software distributed under the License is distributed on an+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+# KIND, either express or implied. See the License for the+# specific language governing permissions and limitations+# under the License.++# Add the expected target version as a label to a merged PR.+# The "target_version" is automatically updated by the dev/update_datafusion_versions.py script.++name: Release Version Labeler++concurrency:+ group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}+ cancel-in-progress: true++on:+ pull_request_target:+ types:+ - closed+ branches:+ - main++jobs:+ label:+ if: github.event.pull_request.merged == true+ runs-on: ubuntu-slim+ permissions:+ pull-requests: write+ steps:+ - name: Add the target release version+ uses: actions/[email protected]+ with:+ script: |+ const labeler = require('./ci/scripts/release_version_labeler.js');+ await labeler({ github, context });diff --git a/ci/scripts/release_version_labeler.js b/ci/scripts/release_version_labeler.jsnew file mode 100644index 0000000000..54a6ac6825--- /dev/null+++ b/ci/scripts/release_version_labeler.js@@ -0,0 +1,49 @@+// Licensed to the Apache Software Foundation (ASF) under one+// or more contributor license agreements. See the NOTICE file+// distributed with this work for additional information+// regarding copyright ownership. The ASF licenses this file+// to you under the Apache License, Version 2.0 (the+// "License"); you may not use this file except in compliance+// with the License. You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing,+// software distributed under the License is distributed on an+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+// KIND, either express or implied. See the License for the+// specific language governing permissions and limitations+// under the License.++// Used by the release_version_labeler workflow++module.exports = async ({ github, context }) => {+ const target_version = 'v56.0.0';++ // create label first if not exists+ try {+ await github.rest.issues.getLabel({+ owner: context.repo.owner,+ repo: context.repo.repo,+ name: target_version+ });+ } catch (error) {+ if (error.status === 404) {+ await github.rest.issues.createLabel({+ owner: context.repo.owner,+ repo: context.repo.repo,+ name: target_version,+ color: '222222'+ });+ } else {+ throw error;+ }+ }++ await github.rest.issues.addLabels({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.payload.pull_request.number,+ labels: [target_version]+ });+};diff --git a/dev/update_datafusion_versions.py b/dev/update_datafusion_versions.pyindex 1edf0f1271..b8c828586c 100755--- a/dev/update_datafusion_versions.py+++ b/dev/update_datafusion_versions.py@@ -121,6 +121,21 @@ def update_docs(path: str, new_version: str):fd.write(content)+def update_ci(new_version: str):+ # release version script+ print("updating ci/scripts/release_version_labeler.js")+ with open("ci/scripts/release_version_labeler.js", 'r+') as fd:+ new_major_version = int(new_version.split(".")[0])+ next_version = f"v{new_major_version + 1}.0.0"+ content = fd.read()+ fd.seek(0)+ content = re.sub(+ r"const target_version = '.*?'", f"const target_version = '{next_version}'", content+ )+ fd.truncate()+ fd.write(content)++def main():parser = argparse.ArgumentParser(description=(@@ -148,6 +163,8 @@ def main():update_docs("docs/source/download.md", new_version)update_docs("docs/source/user-guide/example-usage.md", new_version)update_docs("docs/source/user-guide/crate-configuration.md", new_version)++ update_ci(new_version)if __name__ == "__main__":