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

create release in workflow => attach bundle #128

Merged
merged 38 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ac7f1db
create release in workflow
mki-c2c Jul 30, 2024
eb97cf9
move new code to the top for easier workflow debugging
mki-c2c Jul 30, 2024
da8e0d6
set github token
mki-c2c Jul 30, 2024
daee42b
add owner and repo names
mki-c2c Jul 30, 2024
ab574f8
test CI vars
mki-c2c Jul 30, 2024
155cb1a
debug CI
mki-c2c Jul 30, 2024
a0f1cb4
fixx CI test
mki-c2c Jul 30, 2024
327ba88
get release outputs
mki-c2c Jul 30, 2024
a20e5bb
print outputs
mki-c2c Jul 30, 2024
8ec68d8
clean CI output
mki-c2c Jul 30, 2024
11cb367
use release id
mki-c2c Jul 30, 2024
f0d33e7
fix CI
mki-c2c Jul 30, 2024
4df5ddd
fix typo
mki-c2c Jul 30, 2024
f4fa874
try to find output data
mki-c2c Jul 30, 2024
76199e1
decode answer
mki-c2c Jul 30, 2024
2d609a7
search harder
mki-c2c Jul 30, 2024
62c9369
try harder
mki-c2c Jul 30, 2024
d00331e
found id ?
mki-c2c Jul 30, 2024
233cb19
found nemo (bug)
mki-c2c Jul 30, 2024
aa693e1
upload plain text
mki-c2c Jul 30, 2024
16463ad
move token to env to prevent it from being included in data
mki-c2c Jul 30, 2024
920ce2d
force raw data
mki-c2c Jul 30, 2024
8c8724f
manual upload
mki-c2c Jul 30, 2024
201a861
use env
mki-c2c Jul 30, 2024
14d03e7
bundle real file
mki-c2c Jul 30, 2024
ecc9c70
use PR branch for tag ref
mki-c2c Jul 30, 2024
ae1bb6e
move bundling logics to different workflow
mki-c2c Jul 30, 2024
d71b2ef
change name of workflow
mki-c2c Jul 30, 2024
bf84820
use correct tag name
mki-c2c Jul 30, 2024
97dce13
tar instead of zipping
mki-c2c Jul 30, 2024
c9a7dfe
remove lib bundle from git repo
mki-c2c Jul 30, 2024
7dc183d
create real installable npm tarball
mki-c2c Jul 30, 2024
126505d
split runs for testing
mki-c2c Jul 30, 2024
c92b39e
use regular npm pack and change file name
mki-c2c Aug 1, 2024
78929f6
fix workflow and remove mini package.json
mki-c2c Aug 1, 2024
f3d0bea
upload npm package with sources
mki-c2c Aug 1, 2024
2c4f4b9
must explicitly include bundle (because of .gitignore ?) to pack both…
mki-c2c Aug 1, 2024
349e70a
improve workflow with comments from PR review
mki-c2c Aug 8, 2024
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
44 changes: 44 additions & 0 deletions .github/workflows/ci_bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI_package
on:
push:
tags:
- '*'
jobs:
lux-package:
runs-on: ubuntu-latest
steps:
- name: create release
id: create_release
uses: octokit/[email protected]
with:
# secrets.GITHUB_TOKEN is a secret only valid for one CI execution
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
route: POST /repos/{owner}/{repo}/releases
owner: 'Geoportail-Luxembourg'
repo: 'luxembourg-geoportail'
tag_name: ${{ github.ref }}
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
Copy link
Contributor

Choose a reason for hiding this comment

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

version 16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well this was copied from the GH-pages script, what version should we use ? does it matter for building the bundle ?

cache: 'npm'
- name: Build and pack prod library
shell: bash
run: |
npm ci
npm run build:lib:prod
npm pack

- name: upload manually
run: |
project_name=$(npm run env | grep "npm_package_name" | sed s/npm_package_name=//)
pkg_name=$(ls $project_name-*)
lib_name=$(echo $pkg_name | sed s/luxembourg-geoportail-/luxembourg-geoportail-lib-/)
curl -X POST "https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$lib_name" --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/octet-stream" --data-binary "@$pkg_name"
env:
owner: 'Geoportail-Luxembourg'
repo: 'luxembourg-geoportail'
id: ${{ fromJSON(steps.create_release.outputs.data).id }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# build
/_site/
/dist/
/bundle
/out-tsc/
.parcel-cache

Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ When Lux is used in lib mode 📦, it is possible to oerride i18next configurati

## 📦 Build as a lib for integration (in geoportal v3)

In order to use the new Lux components made with Vuejs as an external dep, follow steps below.
In order to use the new Lux components made with Vuejs as an external dep, the library must be built and imported in the V3 project.

### Build the lib
### Manual Build

In the project **luxembourg-geoportail**, build the app as library with this command:

Expand All @@ -91,6 +91,27 @@ To see what are the components exported, check the `/src/bundle/lib.ts` that is

The build configuration can be found in `vite-dist.config`. It excludes `OpenLayers` and `mapbox-gl` from the lib to prevent problems (eg. in minification) when running the lib within v3. The lib uses the `ol` and `mapbox-gl` instances of v3, which versions should be similar to those in v4.

The results of the build can be found in the folder `bundle`

### Automatic build via CI

An automatic mecanism has been created with github actions. This workflow is triggered when a tag is pushed into the repo.

For the moment there is no automatic tag generation on pull requests, so for dev, the following naming conventions are recommended:
<branch_name>\_tag\_<short_commit>

```
echo $(git rev-parse --abbrev-ref HEAD)_tag_$(git rev-parse --short HEAD)
```

The CI automatically builds the lib, creates a release named after the tag and includes the built bundle in the release. The built package can then be downloaded at the URL:

```
"https://github.com/Geoportail-Luxembourg/luxembourg-geoportail/releases/download/<release_name>/luxembourg-geoportail-lib-0.0.0-dev.tgz"
```

This package URL can also be used to reference the dependency for NPM in package.json, see below

### Import the lib in another app

You can include the built lib multiple ways in the `package.json`:
Expand All @@ -107,8 +128,7 @@ You can include the built lib multiple ways in the `package.json`:
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"luxembourg-geoportail": "git://github.com/Geoportail-Luxembourg/luxembourg-geoportail.git#GSLUX-602-IntegrationV3"
// or "https://github.com/Geoportail-Luxembourg/luxembourg-geoportail.git#GSLUX-602-IntegrationV3"
"luxembourg-geoportail": "ttps://github.com/Geoportail-Luxembourg/luxembourg-geoportail/releases/download/GSLUX-635_create_release_CI_6606389/luxembourg-geoportail-lib-0.0.0-dev.tgz"
},
"devDependencies": {
// ...
Expand Down
52 changes: 0 additions & 52 deletions bundle/assets/locales/app.de.json

This file was deleted.

52 changes: 0 additions & 52 deletions bundle/assets/locales/app.en.json

This file was deleted.

52 changes: 0 additions & 52 deletions bundle/assets/locales/app.fr.json

This file was deleted.

52 changes: 0 additions & 52 deletions bundle/assets/locales/app.lb.json

This file was deleted.

Loading
Loading