stevedlawrence commented on code in PR #1432: URL: https://github.com/apache/daffodil/pull/1432#discussion_r1953299240
########## .github/actions/asf-release-candidate/main.js: ########## @@ -0,0 +1,196 @@ +/** + * 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. + */ + +const fs = require("fs"); +const os = require("os"); +const core = require("@actions/core"); +const github = require("@actions/github"); +const { exec } = require('@actions/exec'); + +async function run() { + try { + const tlp_dir = core.getInput("tlp_dir", { required: true }); + const project_id = core.getInput("project_id", { required: true }); + const project_dir = core.getInput("project_dir"); + const gpg_signing_key = core.getInput("gpg_signing_key", { required: true }); + const svn_username = core.getInput("svn_username", { required: true }); + const svn_password = core.getInput("svn_password", { required: true }); + const nexus_username = core.getInput("nexus_username", { required: true }); + const nexus_password = core.getInput("nexus_password", { required: true }); + let publish = core.getBooleanInput("publish"); + + // import signing key into gpg and get it's key id + let gpg_import_stdout = "" + await exec("gpg", ["--batch", "--import", "--import-options", "import-show"], { + input: Buffer.from(gpg_signing_key), + listeners: { + stdout: (data) => { gpg_import_stdout += data.toString(); } + } + }); + const gpg_signing_key_id = gpg_import_stdout.match("[0-9A-Z]{40}")[0]; + console.info("Using gpgp key id: " + gpg_signing_key_id); + + // tags must be signed with a commiters key, download and import committer + // keys for verification later + let committer_keys = ""; + await exec("curl", [`https://downloads.apache.org/${ tlp_dir }/KEYS`], { + silent: true, + listeners: { + stdout: (data) => { committer_keys += data.toString(); } + } + }); + await exec("gpg", ["--batch", "--import"], { + input: Buffer.from(committer_keys) + }); + + // get the actual project version from the source build configuration--this + // does not have a leading 'v' or -rcX suffix, but might have a -SNAPSHOT + // suffix. Note that regex stuff is a bit specific Daffodil projects. We + // may want to consider requiring projects using this to have a VERSION + // file, and it's up to projects to keep that file in sync with the build + // configuration--most configs can probably just read this file. This is + // really the only part of this action that is specific to Daffodil. + // Everything else would likely work for other ASF projects. + let project_version = ""; + if (fs.existsSync("package.json")) { + project_version = fs.readFileSync("package.json").toString().match(/"version": "(.*)"/)[1]; + } else if (fs.existsSync("build.sbt")) { + project_version = fs.readFileSync("build.sbt").toString().match(/version := "(.*)"/)[1]; + } else { + throw new Error("Could not determine project version from package.json or build.sbt"); + } Review Comment: This is the one thing that is kindof specific to Daffodil, since VS code and Daffodi/SBT Plugin store the version in different files. I think requiring use of a VERSION file doesn't seem too bad. For SBT configs we could read that file and set it to version. We couldn't do the same for VS Code since package.json can't be dynamic like that, but it's probably not too big of a deal to update two files for version bumps. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
