-
Notifications
You must be signed in to change notification settings - Fork 21
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
DEV - Refactor release CI workflow #425
Changes from all commits
67e703a
fca48c0
d3625e2
90716b6
4760961
a9f62d0
493f8ce
2dcbdad
d2f53e1
4ae2946
902fc9c
fc026d7
2b8db4e
a3f7b51
39bcb6e
7adaabb
42b9628
3ca80b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,141 @@ | ||
name: Release conda-store-ui | ||
name: "Build and maybe release conda-store-ui" | ||
|
||
on: | ||
# we want to make a release whenever a new tag is created | ||
release: | ||
types: [published] | ||
push: | ||
tags: | ||
- "*" | ||
branches: [main] | ||
tags: ["*"] | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
call-build: | ||
uses: conda-incubator/conda-store-ui/.github/workflows/build.yml@main | ||
env: | ||
FORCE_COLOR: "1" | ||
PACKAGE_FILE: "conda-store-ui.tgz" | ||
|
||
make-release: | ||
jobs: | ||
# always build and verify | ||
build-application: | ||
name: "Build conda-store-ui" | ||
runs-on: ubuntu-latest | ||
# ensure that the artifacts are available from the build job | ||
needs: call-build | ||
|
||
steps: | ||
- name: "Checkout repository 🛎" | ||
uses: actions/checkout@v4 | ||
|
||
# Setup .npmrc file to publish to npm | ||
- name: "Set up Node.js 🧶" | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "@conda-store-ui" | ||
node-version: "20.x" | ||
cache: "yarn" | ||
|
||
- name: "Install dependencies 📦" | ||
run: yarn | ||
|
||
- name: "Lint code 🔎" | ||
- name: "Lint code 🔍" | ||
run: yarn eslint:check | ||
|
||
- name: "Download webpack bundle 📦" | ||
- name: "Build source code (library) 🏗" | ||
run: yarn run build | ||
|
||
- name: "Build source code (web app) 🏗" | ||
# ensure we use the prod target to minimise assets | ||
run: yarn run webpack:prod bundle | ||
|
||
- name: "Generate package tarball 📦" | ||
run: yarn pack --filename ${{ env.PACKAGE_FILE }} | ||
|
||
- name: "Upload package tarball 📤" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: conda-store-ui-package | ||
path: ${{ env.PACKAGE_FILE }} | ||
|
||
verify-build: | ||
name: "Verify conda-store-ui build" | ||
runs-on: ubuntu-latest | ||
needs: build-application | ||
|
||
steps: | ||
- name: "Checkout repository 🛎" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Download build artefacts 📦" | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: webpack-bundle | ||
path: dist/ | ||
name: conda-store-ui-package | ||
|
||
- name: "Generate package tarball 📦" | ||
run: yarn pack --filename conda-store-ui.tgz | ||
# (setup-node workaround https://github.com/actions/setup-node/issues/763) otherwise the authentication fails for npmjs | ||
- name: "Set npmjs scope" | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
npm config delete @conda-store-ui:registry --location project | ||
npm config set @conda-store-ui:registry 'https://registry.npmjs.org' --location project | ||
npm config set //registry.npmjs.org/:_authToken '${NODE_AUTH_TOKEN}' --location project | ||
|
||
- name: "Set NPM scope" #(setup-node workaround https://github.com/actions/setup-node/issues/763) | ||
- name: "Check publish (dry run) 📤" | ||
run: | | ||
echo "Publishing dry run..." | ||
npm publish --verbose --access public ${{ env.PACKAGE_FILE }} --dry-run | ||
env: | ||
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
release-to-npmjs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we only want to run this job on a release but I can't seem to find anything that prevents the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we want the build and verification to run at all the times and the publish to npmjs only on releases There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Doesn't this result in confusing UX in GitHub? As in, somebody creates a pull request, sees this check, clicks on it, and sees both a build and release job with green check marks, and might think, oh did my pull request trigger a release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose that is when the logs are helpful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and we do have much better logs thanks to you. :) But it's still bad UI, but also maybe not high priority so... just gotta live with it |
||
name: "Release conda-store-ui to npmjs 📦" | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build-application | ||
- verify-build | ||
if: github.repository_owner == 'conda-incubator' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') | ||
# needed for attestations | ||
permissions: | ||
id-token: write | ||
attestations: write | ||
contents: read | ||
|
||
steps: | ||
- name: "Checkout repository 🛎" | ||
uses: actions/checkout@v4 | ||
Comment on lines
+100
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this step needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes if there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right, of course. But hmmm, something about the way the build and release jobs are split up still feels unintuitive to me... can't quite put my finger on it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know why this is a rather standard approach. If you build on every PR and merge to main basically you are following continuous delivery practices -> ensures that when you need to develop and release this is is working as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mean the fact that they are split up, more about how... but it's not important, this can be iterated on later :) |
||
|
||
# Set registry in .npmrc and set up auth to read in from | ||
# env.NODE_AUTH_TOKEN. | ||
- name: "Set up Node.js 🧶" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this step needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes so that we have an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah... I started playing with this, and for some reason, if you use this action with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not magically work - I am using the See actions/setup-node#763 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, I was agreeing with you here that this step is necessary. It's just sad to me that these two things are not at all clearly related. It's side effect dependencies. I think a comment like the following would be helpful to people later:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I don't understand why we keep linking to actions/setup-node#763. That issue is irrelevant. It's only relevant if you're using the GitHub package registry, which we're not using. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it is not, that is what I am trying to explain. That issue is relevant as it's the only issue where I found useful steps to properly set the context and authentication. Hence why I left it as a comment. |
||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "@conda-store-ui" | ||
|
||
- name: "Download build artefacts 📦" | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: conda-store-ui-package | ||
|
||
# Create an attestation with GitHub to track build provenance | ||
# More info: https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds | ||
- name: "Attest Build Provenance ✨" | ||
trallard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: actions/attest-build-provenance@v1 | ||
if: github.repository_owner == 'conda-incubator' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') | ||
with: | ||
subject-path: ${{ env.PACKAGE_FILE }} | ||
|
||
# (setup-node workaround https://github.com/actions/setup-node/issues/763) otherwise the authentication fails for npmjs | ||
- name: "Set npmjs scope" | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
npm config delete @conda-store-ui:registry --location project | ||
npm config set @conda-store-ui:registry 'https://registry.npmjs.org' --location project | ||
npm config set //registry.npmjs.org/:_authToken '${NPM_AUTH_TOKEN}' --location project | ||
npm config set //registry.npmjs.org/:_authToken '${NODE_AUTH_TOKEN}' --location project | ||
|
||
- name: "Check npmjs/conda-store-ui scope" | ||
run: npm show | ||
|
||
- name: "Publish to npm 📤" | ||
run: | | ||
echo "Publishing with tag ${{ env.GITHUB_REF_NAME }}" | ||
npm publish --verbose --access public conda-store-ui.tgz | ||
npm publish --verbose --access public ${{ env.PACKAGE_FILE }} | ||
env: | ||
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,5 @@ static | |
!.yarn/sdks | ||
!.yarn/versions | ||
.pnp.*# | ||
|
||
.bun.lockb |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ | |
"node": ">=18.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
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.
Changed the name because it was confusing seeing this in the UI and on my terminal when tracking CI runs