Main #221
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
workflow_run: | |
workflows: ["Hotfix"] | |
types: | |
- completed | |
# Manually trigger the workflow | |
workflow_dispatch: | |
jobs: | |
lint: | |
uses: nuxeo/nuxeo-admin-console-ui/.github/workflows/lint.yaml@main | |
secrets: | |
NPM_PACKAGES_TOKEN: ${{ secrets.NPM_PACKAGES_TOKEN }} | |
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | |
test: | |
uses: nuxeo/nuxeo-admin-console-ui/.github/workflows/utest.yaml@main | |
secrets: | |
NPM_PACKAGES_TOKEN: ${{ secrets.NPM_PACKAGES_TOKEN }} | |
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | |
build: | |
needs: [lint, test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- run: git config user.name "nuxeo-webui-jx-bot" && git config user.email "[email protected]" | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: ${{ env.NEXUS_URL }} | |
scope: '@nuxeo' | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: 'Update settings.xml with server configuration' | |
run: | | |
echo '<settings> | |
<servers> | |
<server> | |
<id>maven-internal</id> | |
<username>${{ secrets.PACKAGES_AUTH_USER }}</username> | |
<password>${{ secrets.PACKAGES_AUTH_TOKEN }}</password> | |
</server> | |
</servers> | |
</settings>' > ~/.m2/settings.xml | |
- name: Configure .npmrc | |
working-directory: nuxeo-admin-console-web/angular-app | |
run: | | |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }}" >> .npmrc | |
- name: Prepare Environment | |
run: | | |
echo "BRANCH_NAME=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV | |
pushd nuxeo-admin-console-web/angular-app | |
echo $(npx -c 'echo "$npm_package_version"') | |
echo "PACKAGE_VERSION=$(npx -c 'echo "$npm_package_version"')" >> $GITHUB_ENV | |
popd | |
- name: Get Prerelease Version | |
run: | | |
echo "Beta Release Version" | |
echo ${{secrets.BETA_RELEASE_VERSION}} | sed 's/./& /g' | |
echo "VERSION=${{ secrets.BETA_RELEASE_VERSION }}" >> $GITHUB_ENV | |
- name: Update Version ${{env.VERSION}} | |
run: | | |
# find . -type f -not -path "./node_modules/*" -regex ".*\.\(yaml\|sample\|json\)" -exec sed -i 's/'"${{env.PACKAGE_VERSION}}"'/'"${{env.VERSION}}"'/g' {} \; | |
# set padded version to build package for connect preprod | |
PADDED=$(printf '%03d' $(echo ${{env.VERSION}} | sed -r s/[0-9]+\.[0-9]+\.[0-9]+-beta\.\([0-9]+\)/\\1/g)) | |
PADDED_VERSION=$(echo ${{env.VERSION}} | sed -E "s/([0-9]+\.[0-9]+\.[0-9]+-beta\.)[0-9]+/\\1$PADDED/g") | |
echo "PADDED_VERSION=$PADDED_VERSION" >> $GITHUB_ENV | |
find . -type f -not -path "./node_modules/*" -regex ".*\.\(xml\)" -exec sed -i 's/'"${{env.PACKAGE_VERSION}}"'/'"$PADDED_VERSION"'/g' {} \; | |
sed -i -e 's/\${project.version}/'"$PADDED_VERSION"'/g' nuxeo-admin-console-package/pom.xml | |
pushd nuxeo-admin-console-web/angular-app | |
npm version ${{env.VERSION}} --no-git-tag-version | |
popd | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Install Angular CLI | |
run: npm install -g @angular/cli | |
- name: Install Dependencies | |
working-directory: nuxeo-admin-console-web/angular-app | |
run: npm install | |
- name: Restore Maven cache | |
uses: skjolber/maven-cache-github-action@v1 | |
with: | |
step: restore | |
- name: Build Angular Project | |
run: mvn package | |
- name: Save Maven cache | |
uses: skjolber/maven-cache-github-action@v1 | |
with: | |
step: save | |
- name: Archive Package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: | | |
nuxeo-admin-console-package/target/nuxeo-admin-console-*.zip | |
- name: Tag | |
run: | | |
git add nuxeo-admin-console-web/angular-app/package-lock.json | |
git commit -a -m "Release ${{env.VERSION}}" | |
git tag -a v${{env.VERSION}} -m "Release ${{env.VERSION}}" | |
git push origin v${{env.VERSION}} | |
- name: Publish on Pre-Prod Marketplace | |
working-directory: nuxeo-admin-console-package/target | |
env: | |
CONNECT_PREPROD_URL: https://nos-preprod-connect.nuxeocloud.com/nuxeo | |
run: | | |
PACKAGE="nuxeo-admin-console-${{env.PADDED_VERSION}}.zip" | |
STATUS_CODE=`curl -i --silent --output publish-req.output -w "%{http_code}" -u "${{ secrets.CONNECT_PREPROD_AUTH }}" -F package=@$PACKAGE "$CONNECT_PREPROD_URL/site/marketplace/upload?batch=true"` | |
cat publish-req.output | |
if [[ "$STATUS_CODE" != "200" ]] | |
then | |
exit 1 | |
else | |
exit 0 | |
fi |