Skip to content

Commit

Permalink
Update the packages publishing workkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaKhD committed Dec 12, 2023
1 parent 9163683 commit 1027095
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 16 deletions.
107 changes: 91 additions & 16 deletions .github/workflows/packages_publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ name: Publishing to GitHub Packages
on:
workflow_dispatch:
inputs:
pattern:
filter:
type: string
description: Package file pattern
description: Package file filter pattern
required: false
set-timestamp-version:
type: boolean
description: Set timestamp version
required: false
default: true
move-next-tag:
type: boolean
description: Move 'next' tag
required: false
default: true
move-stable-tag:
type: boolean
description: Move 'stable' tag
required: false
default: false

jobs:

build:
name: Build packages
runs-on: ubuntu-latest

outputs:
packages: ${{ steps.filter.outputs.packages }}
steps:
- name: Get sources
uses: actions/checkout@v4
Expand All @@ -21,28 +38,86 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
always-auth: true

- name: Install dependencies
run: npm install --no-audit --no-fund

- name: Set timestamp version
if: ${{ inputs.set-timestamp-version }}
run: npm run ts-script build/set-timestamp-version

- name: Build npm packages
env:
BUILD_INTERNAL_PACKAGE: true
run: npm run all:build

- name: Publish to npm.pkg.github.com
- name: Build artifacts package
run: npm run ts-script build/make-artifacts-package

- uses: actions/upload-artifact@v3
with:
name: packages
path: artifacts/npm/*.tgz

- name: Filter packages
id: filter
working-directory: artifacts/npm
run: ls *.tgz | grep -E -i '${{ inputs.filter }}' | sed -r 's/^(.*)$/"\1"/g' | paste -sd "," - | sed -r 's/(.*)/packages=[\1]/' >> "$GITHUB_OUTPUT"


publish:
name: Publish package
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.build.outputs.packages) }}
steps:

- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: packages

- name: Publish to npm.pkg.github.com
id: publish
env:
PACKAGE: ${{ matrix.package }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUTHOR: ${{ github.repository_owner }}
# --ignore-scripts is required for publishing devextreme-angular which fails with error:
# 'Trying to publish a package that has been compiled by Ivy in full compilation mode.'
# Should be removed.
run: |
tar -xzf $PACKAGE
cd package
npm init -y --scope $AUTHOR
npm pkg delete repository
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm publish --quiet --ignore-scripts --registry https://npm.pkg.github.com
npm pkg get name --workspaces=false | tr -d '"' | sed -r 's/(.*)/name=\1/' >> "$GITHUB_OUTPUT"
npm pkg get version --workspaces=false | tr -d '"' | sed -r 's/(.*)/version=\1/' >> "$GITHUB_OUTPUT"
npm pkg get version --workspaces=false | tr -d '"' | sed -r 's/([0-9]+\.[0-9]+).*/majorVersion=\1/' >> "$GITHUB_OUTPUT"
- name: Move 'next' tag
if: ${{ inputs.move-next-tag }}
env:
PACKAGE_NAME: ${{ steps.publish.outputs.name }}
PACKAGE_VERSION: ${{ steps.publish.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.publish.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm --registry=https://npm.pkg.github.com dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-next
- name: Move 'stable' tag
if: ${{ inputs.move-stable-tag }}
env:
PACKAGE_NAME: ${{ steps.publish.outputs.name }}
PACKAGE_VERSION: ${{ steps.publish.outputs.version }}
PACKAGE_VERSION_MAJOR: ${{ steps.publish.outputs.majorVersion }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ls *.tgz | grep --extended-regexp --ignore-case '${{ inputs.pattern }}' |
while read filename; do
tar -xzf ${filename};
pushd package;
sed -i '/\"repository\"/,/}/ d; /^$/d' package.json;
npm init -y --scope ${{ github.repository_owner }};
npm publish --dry-run --quiet --registry https://npm.pkg.github.com;
popd;
rm -r package;
done
run: |
npm set //npm.pkg.github.com/:_authToken="$NODE_AUTH_TOKEN"
npm --registry=https://npm.pkg.github.com dist-tag add $PACKAGE_NAME@$PACKAGE_VERSION $PACKAGE_VERSION_MAJOR-stable
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "devextreme-monorepo",
"version": "23.2.3",
"license": "MIT",
"author": "Developer Express Inc.",
"scripts": {
"devextreme:inject-descriptions-to-bundle": "dx-tools inject-descriptions --target-path ./packages/devextreme/ts/dx.all.d.ts --artifacts ./artifacts/internal-tools",
"devextreme:inject-descriptions-to-modules": "dx-tools inject-descriptions --collapse-tags --sources ./packages/devextreme/js --artifacts ./artifacts/internal-tools",
Expand All @@ -21,6 +22,7 @@
"regenerate-all": "nx run-many -t regenerate",
"lint-staged": "lint-staged",
"prepare": "husky install",
"ts-script": "ts-node",
"all:update-version": "ts-node build/update-version.ts",
"all:build": "ts-node build/build-all.ts"
},
Expand Down

0 comments on commit 1027095

Please sign in to comment.