Skip to content

v0.12.4-canary.2

v0.12.4-canary.2 #6

name: Release Zimic Package
on:
release:
types:
- published
concurrency:
group: release-zimic-${{ github.ref_name }}
cancel-in-progress: false
env:
NODE_VERSION: 22
TURBO_LOG_ORDER: stream
jobs:
release-to-npm:
name: Release to NPM
runs-on: ubuntu-latest
timeout-minutes: 7
environment: NPM
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get zimic release version
id: zimic-version
uses: ./.github/actions/zimic-version
with:
project-directory: packages/zimic
validate-ref-name: ${{ github.ref_name }}
- name: Set up Zimic
uses: ./.github/actions/zimic-setup
with:
node-version: ${{ env.NODE_VERSION }}
node-registry-url: https://registry.npmjs.org
install: zimic...
build: zimic^...
- name: Build Zimic
run: pnpm turbo build --filter zimic
- name: Release to NPM
working-directory: packages/zimic
run: pnpm publish --no-git-checks --tag ${{ steps.zimic-version.outputs.label }}
env:
NODE_AUTH_TOKEN: ${{ secrets.ZIMIC_NPM_RELEASE_TOKEN }}
NPM_CONFIG_PROVENANCE: true
test-npm-release:
name: Test NPM release
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- release-to-npm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Zimic release version
id: zimic-version
uses: ./.github/actions/zimic-version
with:
project-directory: packages/zimic
validate-ref-name: ${{ github.ref_name }}
- name: Set up Zimic
uses: ./.github/actions/zimic-setup
id: zimic-setup
with:
node-version: ${{ env.NODE_VERSION }}
install: '"zimic-test-client..." "zimic-example*..."'
build: '"zimic-test-client^..." "zimic-example*^..."'
- name: Test released package
run: |
sed -i \
's/link-workspace-packages = true/link-workspace-packages = false/' \
.npmrc
echo "Using zimic@${{ steps.zimic-version.outputs.value }} for testing..."
for file in apps/zimic-test-client/package.json examples/package.json examples/*/package.json; do
sed -E -i \
's/"zimic([0-9]?)": ".*"/"zimic\1": "npm:zimic@${{ steps.zimic-version.outputs.value }}"/' \
$file
done
timeout 60s bash -c '
until pnpm view zimic versions --json | grep --quiet "${{ steps.zimic-version.outputs.value }}"; do
echo "zimic@${{ steps.zimic-version.outputs.value }} is not yet available on NPM..."
sleep 5
echo "Checking again..."
done
'
echo "zimic@${{ steps.zimic-version.outputs.value }} is now available on NPM!"
timeout 90s bash -c '
until pnpm install --no-frozen-lockfile ${{ steps.zimic-setup.outputs.install-filters }}; do
sleep 5
echo "Retrying..."
done
'
pnpm turbo \
types:check lint:turbo \
--continue \
--concurrency 100% \
${{ steps.zimic-setup.outputs.install-filters }}
pnpm turbo \
test:turbo \
--continue \
--concurrency 100% \
${{ steps.zimic-setup.outputs.install-filters }}
release-docs:
name: Release documentation
runs-on: ubuntu-latest
timeout-minutes: 5
environment: Wiki
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: zimic
- name: Get Zimic release version
id: zimic-version
uses: ./zimic/.github/actions/zimic-version
with:
project-directory: zimic/packages/zimic
validate-ref-name: ${{ github.ref_name }}
- name: Checkout wiki
uses: actions/checkout@v4
if: ${{ steps.zimic-version.outputs.label == 'latest' }}
with:
repository: zimicjs/zimic.wiki
path: zimic.wiki
ssh-key: ${{ secrets.RELEASE_GITHUB_PUSH_KEY }}
- name: Sync wiki content
working-directory: zimic
if: ${{ steps.zimic-version.outputs.label == 'latest' }}
run: |
bash scripts/docs/sync-wiki.sh '${{ github.ref_name }}'
- name: Commit and push wiki changes
working-directory: zimic.wiki
if: ${{ steps.zimic-version.outputs.label == 'latest' }}
run: |
git config user.name '${{ vars.RELEASE_COMMIT_USER_NAME }}'
git config user.email '${{ vars.RELEASE_COMMIT_USER_EMAIL }}'
git add .
git commit -m 'docs(wiki): zimic@${{ steps.zimic-version.outputs.value }}'
git push
publish-release-comments:
name: Publish Zimic release comments
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- release-to-npm
- test-npm-release
- release-docs
permissions:
issues: write
pull-requests: write
steps:
- name: Create release comments and close milestone
uses: actions/github-script@v7
with:
script: |
const DELAY_BETWEEN_COMMENTS = 1000;
const PER_PAGE = 100;
const tag = context.ref.replace(/^refs\/tags\//, '');
const version = tag.replace(/^v/, '');
const { owner, repo: repository } = context.repo;
let milestone = undefined;
for (let page = 1; milestone === undefined; page++) {
console.log(`Fetching milestone ${tag}... (page ${page})`);
const milestones = await github.rest.issues.listMilestones({
owner,
repo: repository,
state: 'open',
page,
per_page: PER_PAGE,
});
milestone = milestones.data.find((milestone) => milestone.title === tag);
if (milestones.data.length < PER_PAGE) {
break;
}
}
if (milestone) {
console.log(`Milestone ${tag} found.`);
for (let page = 1; ; page++) {
console.log(`Fetching issues and pull requests with milestone ${tag}... (page ${page})`);
const issues = await github.rest.issues.listForRepo({
owner,
repo: repository,
milestone: milestone.number,
state: 'all',
page,
per_page: PER_PAGE,
});
for (const issue of issues.data) {
console.log(`Creating release comment on #${issue.number}...`);
try {
await github.rest.issues.createComment({
owner,
repo: repository,
issue_number: issue.number,
body: [
`### Released in [${tag}](https://github.com/${owner}/${repository}/releases/tag/${tag}) :tada:\n`,
`- [**:pushpin: Release notes**](https://github.com/${owner}/${repository}/releases/tag/${tag})`,
`- [**:package: NPM package**](https://www.npmjs.com/package/${repository}/v/${version})`,
].join('\n'),
});
console.log(`Release comment created on #${issue.number}.`);
await new Promise((resolve) => setTimeout(resolve, DELAY_BETWEEN_COMMENTS));
} catch (error) {
console.error(`Could not create release comment on #${issue.number}.`);
console.error(error);
await new Promise((resolve) => setTimeout(resolve, DELAY_BETWEEN_COMMENTS * 5));
}
}
if (issues.data.length < PER_PAGE) {
break;
}
}
console.log(`Closing milestone ${tag}...`);
await github.rest.issues.updateMilestone({
owner,
repo: repository,
milestone_number: milestone.number,
state: 'closed',
});
console.log('All done!');
} else {
console.warn(`Milestone ${tag} not found.`);
}