Skip to content

Commit

Permalink
chore: enable provenance statements and export updates (#1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnixon committed Aug 22, 2024
1 parent 4b00ef1 commit e0f1a15
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/release-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
jobs:
Release:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
Expand All @@ -32,17 +34,29 @@ jobs:
run: yarn

- name: Continuous integration check & build
run: yarn ci-check

#- name: Commit exports
# run: |
# git add src/index.js
# git commit -m "new exports"
id: ci-check
run: |
yarn ci-check
git diff --quiet src/index.js || echo EXPORTS_UPDATED=true >> "$GITHUB_OUTPUT"
echo "### Changed exports" >> $GITHUB_STEP_SUMMARY
echo "```diff" >> $GITHUB_STEP_SUMMARY
git diff src/index.js >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
- name: Commit exports
if: ${{ steps.ci-check.outputs.EXPORTS_UPDATED == 'true' }}
run: |
git add src/index.js
git commit -m "new exports"
git push
# Dry run - `yarn lerna version prepatch --no-git-tag-version --no-push --yes`
# With dist tag - `run: yarn lerna publish prepatch --dist-tag next --yes`
- name: Publish
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_LERNA }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: yarn lerna publish patch --ignore-changes src/index.js --create-release github --yes
run: |
yarn lerna version patch --ignore-changes src/index.js --create-release github --yes
npm publish --provenance
15 changes: 13 additions & 2 deletions addNamedComponentExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const NEW_LINE_ENTITY = '\n';
const COMPONENTS_PATH = path.join(__dirname, './src/components/');
const FILE_ENCODING = 'utf8';
const INDEX_FILE_PATH = path.join(__dirname, './src/index.js');
const INDEX_EXPORT_MARKER = '// AUTO-GENERATED EXPORTS - DO NOT EDIT BELOW';

/**
* regex from index.js extended by: not starting from underscore
Expand All @@ -29,12 +30,22 @@ let componentsExports = [];
function addNamedComponentExports(dir) {
readFilesFromPath(dir);

const indexFileContent = fs.readFileSync(INDEX_FILE_PATH, FILE_ENCODING);
let indexFileContent = fs.readFileSync(INDEX_FILE_PATH, FILE_ENCODING);
const exportsContent = componentsExports.join(NEW_LINE_ENTITY);
const fileContentToSave = indexFileContent + exportsContent + NEW_LINE_ENTITY;

if (exportsWereAddedToIndex(indexFileContent, exportsContent)) return;

// remove existing exports
const automaticExports = indexFileContent.indexOf(INDEX_EXPORT_MARKER);
if (automaticExports > -1) {
indexFileContent = indexFileContent.substring(
0,
automaticExports + INDEX_EXPORT_MARKER.length + NEW_LINE_ENTITY.length
);
}

const fileContentToSave = indexFileContent + exportsContent + NEW_LINE_ENTITY;

fs.writeFileSync(INDEX_FILE_PATH, fileContentToSave, FILE_ENCODING);
}

Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default {
}
},
};

// AUTO-GENERATED EXPORTS - DO NOT EDIT BELOW
export { default as CvAccordion } from './components/CvAccordion/CvAccordion.vue';
export { default as CvAccordionItem } from './components/CvAccordion/CvAccordionItem.vue';
export { default as CvAccordionSkeleton } from './components/CvAccordion/CvAccordionSkeleton.vue';
Expand Down

0 comments on commit e0f1a15

Please sign in to comment.