-
Notifications
You must be signed in to change notification settings - Fork 33
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
Workflows for automated releases and github-pages builds #3137
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow differs slightly from what we have in other repos:
- Create a release on Github on https://github.com/Kinto/kinto-admin/releases/new
- Create a new tag
vX.Y.Z
(This tag will be created from the target when you publish this release.) - Generate release notes
- Publish release
If possible it would be better to align it with the rest. As far as I understand, it only means making sure the release.yml
workflow does not try to create the release when it already exists, and would just add attachments.
Also, I think we may want to deploy official versions on Github pages automatically.
README.md
Outdated
5. Publish the release when ready | ||
|
||
## Deploying to github-pages | ||
A github workflow is included that will release to github pages for any user acceptence testing you may want to do. You must enable github pages first and allow deployment from github actions (Settings > Pages). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to deploy to Github pages automatically on tags?
You must enable github pages first and allow deployment from github actions
What does it mean? Approve deployments?
README.md
Outdated
## Deploying to github-pages | ||
A github workflow is included that will release to github pages for any user acceptence testing you may want to do. You must enable github pages first and allow deployment from github actions (Settings > Pages). | ||
|
||
By default, most branches are restricted from deploying. Additional branches can be allowed to deploy (or any can be allowed) under Settings > Environments > github-pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer with two parts:
- automated deployment on release (along with the releasing info)
- how to deploy custom branch on gh-pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to make all of this a little clearer. Will read it again tomorrow to see if it still makes sense though.
Co-authored-by: Mathieu Leplatre <mathieu@leplat.re>
Seems like there are two easy ways to make that happen, which sounds better to you?
|
I vote this one 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there are two easy ways to make that happen, which sounds better to you?
- Kick off gh-pages.yml after release.yml runs
- Have gh-pages.yml also listen for tag creation
I would vote for 2. But no strong opinion.
.github/workflows/release.yml
Outdated
cd build | ||
tar -cvf "$RUNNER_TEMP/kinto-admin-release.tar" * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
cd build | |
tar -cvf "$RUNNER_TEMP/kinto-admin-release.tar" * | |
tar -cvf --cd build/ "$RUNNER_TEMP/kinto-admin-release.tar" * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have --cd
as a valid option on my machine or on the ubuntu 22.04 docker container I just pulled. And I don't see it in the manual. Is this some non-standard thing or am I totally overlooking it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Under "Build and deployment" choose Source > GitHub Actions | ||
2. Choose which branches should be allowed to deploy to pages | ||
1. Go Settings > Environments > Github Pages | ||
2. Under "Deployment branches and tags", configure which branches should be allowed to deploy to pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something that I find unclear in these instructions...
Are they meant to be ran each time? Are they targeted at contributors/forks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to make that clearer
2. Select the "Deploy to Github Pages" action | ||
3. Select "Run workflow" and choose the branch you wish to build against | ||
4. Click "Run workflow" | ||
5. Kinto-admin will be deployed to `https://{owner}.github.io/kinto-admin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why {owner}
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{owner}
is the syntax I've seen in the github docs. So the for kinto's repo this would be https://kinto.github.io/kinto-admin
, but for my fork it's https://alexcottner.github.io/kinto-admin/
. Is there a way to make this clearer?
|
2. When tagging your release, enter a standard version number like `vX.Y.Z` | ||
3. After the release is published (including pre-release), built assets will be attached as files, including: | ||
1. Source code based on the tagged commit | ||
2. A single-server build for kinto-admin in a tar file (this may take a few minutes to show up) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. A single-server build for kinto-admin in a tar file (this may take a few minutes to show up) | |
2. A single-server build meant to be used in a `kinto` installation in a tar file (this may take a few minutes to show up) |
Do you think we should explicitly mention that we're setting ASSET_PATH
and SINGLE_SERVER
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being verbose can't hurt. Will add.
.github/workflows/release.yml
Outdated
LATEST_TAG=$(echo $GITHUB_REF | sed s/^v// | tr -d '"') | ||
VERSION_NUMBER=".version=\"${LATEST_TAG}\"" | ||
jq ${VERSION_NUMBER} package.json > temp_package.json | ||
mv temp_package.json package.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with doing this only in CI is that if people build Kinto Admin the "old" way to customize build variables (that is, curl
the source code then run npm run build
), the version won't be overwritten.
What if we handled this in vite.config.ts
instead? Here's a quick example that only gets the latest tag, but perhaps we could write a function that encompases all of the logic currently in the action workflow:
diff --git a/vite.config.ts b/vite.config.ts
index 9817bd7..f2d2111 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,6 +2,8 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
+import { execSync } from 'child_process'
+
/**
* used to set the relative path from which we expect to serve the admin's
* static bundle on the server:
@@ -9,7 +11,7 @@ import react from '@vitejs/plugin-react'
* Kinto plugin: /v1/admin/
*/
const ASSET_PATH = process.env.ASSET_PATH || "/";
-
+const KINTO_ADMIN_VERSION = execSync('git describe --tags --abbrev=0').toString()
// https://vitejs.dev/config/
export default defineConfig({
server: {
@@ -19,7 +21,7 @@ export default defineConfig({
plugins: [react()],
base: ASSET_PATH,
define: {
- KINTO_ADMIN_VERSION: JSON.stringify(process.env.npm_package_version),
+ KINTO_ADMIN_VERSION: JSON.stringify(KINTO_ADMIN_VERSION)
},
build: {
outDir: "build"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like that this simplifies things. I'll combine this with @leplatrem 's suggestion above to do a --abbrev=4
. If they're exactly on a tag, it'll just be the tag name returned. If they're beyond that tag, it'll note how far ahead they are and which sha they're on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented!
.github/workflows/release.yml
Outdated
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
fail_on_unmatched_files: true | ||
files: ${{ runner.temp }}/kinto-admin-release.tar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it works just fine, so consider this comment optional, but it might be nice if we don't have to rely on a 3rd party action for this. It looks like the gh
CLI has a release command built in -- maybe that'd work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I settled on this one after finding actions/create-release being archived/unsupported and it's read-me mentioning this one and it seeming simple enough for our needs.
I'll look into the cli option to see what that takes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 The ghpages section in the docs is a lot clearer with these titles , thanks for your patience 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Does this also mean we can rip out the publish-to-gh-pages
command and gh-pages
dependency?
Oh yes, I'll do that. I forgot to remove those because my plan A was to use them, but that didn't work out. |
Example links
GitHub Pages Deployment
This will happen automatically upon release publish, or manually whenever a user wants to create a demo build for user acceptance testing. Added notes in readme.md for fork repo configuration and notes on the actions.
Automatic Release Creation on Tags
When a tag is created that matches the
v{major}.{minor}.{build}
pattern, this workflow will:Open Questions
Misc
Commits will be squashed on merge to make this clean.