Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fcos-release-notes: add job for generating release notes #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,38 @@ lock(resource: "build-${params.STREAM}") {
/var/tmp/fcos-releng/coreos-meta-translator/trans.py --workdir .
""")

// Replace the 'next-release' field in 'release-notes.yaml' field
// with the real build id
botCreds = "github-coreosbot-token"
config_repo = "coreos/fedora-coreos-config"
release_notes_yaml = "src/config/release-notes.yaml"
utils.shwrap("""
/var/tmp/fcos-releng/coreos-release-note-generator/release-note-generator.py update \
--release-notes-file ${release_notes_yaml} \
--build-id ${buildID} \
--output-dir src/config
""")
shwrap("""
cd src/config
git commit -am "release-notes.yaml: replace 'next-release' with build id"
""")
withCredentials([usernamePassword(credentialsId: botCreds,
usernameVariable: 'GHUSER',
passwordVariable: 'GHTOKEN')]) {
// should gracefully handle race conditions here
sh("git push https://\${GHUSER}:\${GHTOKEN}@github.com/${config_repo} ${params.STREAM}")
}

// Push 'release-notes.yaml' to S3 bucket for website consumption
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws-fcos-builds-bot']]) {
shwrap("""
cd src/config
aws s3 sync --acl public-read --cache-control 'max-age=60' \
--exclude '*' --include 'release-notes.yaml' \
./ s3://fcos-builds
""")
}

Copy link
Author

Choose a reason for hiding this comment

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

Something in my mind keeps telling me this is not correct / desired. Since Jenkinsfile primarily used only used cosa, and not sure if I could use botCreds and aws-fcos-builds-bot here. The logic comes from bump-lockfile.Jenkinsfile and sync-stream-metadata.Jenkinsfile.

Could you sanity check please? @jlebon

Copy link
Member

Choose a reason for hiding this comment

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

Still trying to understand how everything fits together (so the next statements might not fit with the intended design), but ISTM like we shouldn't do anything related to release notes as part of the main build pipeline. That should instead be in the release job (or a job triggered by the release job), and only on production streams.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. Discussed at #261 (comment).

if (s3_stream_dir) {
// just upload as public-read for now, but see discussions in
// https://github.com/coreos/fedora-coreos-tracker/issues/189
Expand Down
70 changes: 70 additions & 0 deletions jobs/generate-release-notes.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@Library('github.com/coreos/coreos-ci-lib@master') _

config_repo = "coreos/fedora-coreos-config"
releng_script_repo = "coreos/fedora-coreos-releng-automation"
branches = [
"testing-devel"
"next-devel"
]
botCreds = "github-coreosbot-token"

cosaPod {
// set up fedora-coreos-releng-automation repository
shwrap("""
mkdir fcos-releng
git clone --branch master https://github.com/${releng_script_repo} fcos-releng"
git config --global user.name "CoreOS Bot"
git config --global user.email "coreosbot@fedoraproject.org"
""")

parallel branches.collectEntries { branch -> [branch, {
// build 'release-notes.yaml' using 'release-notes.d/' under testing-devel and next-devel
stage("Build 'release-notes.yaml'") {
shwrap("mkdir ${branch}")

dir(branch) {
shwrap("cosa init --branch ${branch} https://github.com/${config_repo}")
Copy link
Member

@dustymabe dustymabe Aug 17, 2020

Choose a reason for hiding this comment

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

Do we need to use cosa here? Should we just use git clone --depth=1 instead?

Copy link
Author

Choose a reason for hiding this comment

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

All I needed was a FCOS config repo so no hard need for a cosa init.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's just use git clone --depth=1 to keep things simple then.

}

// generate 'release-notes.yaml' from yaml snippets under 'config/release-notes.d/'
dir("fcos-releng") {
shwrap("python3 coreos-release-note-generator/release-note-generator.py build \
--config-dir ~/${branch}/src/config \
--output-dir ~/${branch}/src/config")
}
}

// delete all 'release-notes.d/*.yaml' files for next release version
stage("Clean up 'release-notes.d/'") {
shwrap("""
cd ${branch}/src/config
git checkout ${branch}
rm -rf release-notes.d/*.yaml
Copy link
Member

Choose a reason for hiding this comment

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

we probably need to use git rm here and git commit -m below.

git commit -am "release-notes.d: clean up release-notes.d for next release"
""")
withCredentials([usernamePassword(credentialsId: botCreds,
usernameVariable: 'GHUSER',
passwordVariable: 'GHTOKEN')]) {
// should gracefully handle race conditions here
sh("git push https://\${GHUSER}:\${GHTOKEN}@github.com/${config_repo} ${branch}")
Comment on lines +48 to +49
Copy link
Member

Choose a reason for hiding this comment

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

doing a git pull --rebase before doing the git push might help with race conditions.

}
}

// push 'release-notes.yaml' from testing-devel and next-devel to testing and next branch correspondingly
stage("Push 'release-notes.yaml'") {
target_branch = branch.replace("-devel", "")
shwrap("""
cd ${branch}/src/config
git checkout ${target_branch}
git add release-notes.yaml
git commit -am "release-notes.yaml: generate latest release notes"
""")
withCredentials([usernamePassword(credentialsId: botCreds,
usernameVariable: 'GHUSER',
passwordVariable: 'GHTOKEN')]) {
// should gracefully handle race conditions here
sh("git push https://\${GHUSER}:\${GHTOKEN}@github.com/${config_repo} ${target_branch}")
}
}
}] }
}