From 28f66d83737e111c0e2104d2094550b48a71dbf6 Mon Sep 17 00:00:00 2001 From: Nikolai Wotton Date: Wed, 5 Jun 2024 17:49:14 -0400 Subject: [PATCH] foobar --- .github/workflows/release.yml | 78 +++++++++++++++++++++++++--- .github/workflows/release_shared.yml | 7 ++- .github/workflows/tests.yml | 5 +- packages/npm/financekit/package.json | 10 ++-- packages/npm/send/package.json | 10 ++-- 5 files changed, 86 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c1e425..d6cc036 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,19 +3,85 @@ name: Release on: push: branches: - - main + - foobar2 jobs: - release: + publish-npm-packages: strategy: fail-fast: false matrix: - workingDirectory: [ - "packages/npm/send", - "packages/npm/financekit", - ] + workingDirectory: ["packages/npm/send", "packages/npm/financekit"] uses: ./.github/workflows/release_shared.yml with: workingDirectory: ${{ matrix.workingDirectory }} secrets: inherit name: ${{ matrix.workingDirectory }} + + publish-github-release-and-tag: + # If this is not here, CICD committing the changelog back will kick off a job to commit back the changelog (infinite loop) + if: github.actor != 'candle-admin' + runs-on: ubuntu-latest + needs: [publish-npm-packages] + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.CANDLE_ADMIN_PAT }} + + # This would need to run for all of them, ideally in parallel...should see if things can be done without this step + # - name: Setup + # uses: ./.github/actions/setup + # with: + # workingDirectory: ${{ inputs.workingDirectory }} + + # TODO: If stuff like this is needed, can use bash parallelization &/wait + # Hopefully not needed... ? + # - name: Build package + # run: yarn prepare + + - name: Re-configure publishing + run: | + # sed -i 's# "registry": "https://npm.pkg.github.com/"# "registry": "https://registry.npmjs.org/"#' packages/npm/*/package.json + declare -a packages=["packages/npm/send", "packages/npm/financekit"] + for package in "${packages[@]}"; do + cd $package + yarn release + echo "currentTag=$(git tag --points-at HEAD)" >> $GITHUB_ENV + git tag -d $(git tag -l) + git reset HEAD~ + git update-index --assume-unchanged CHANGELOG.md + git update-index --assume-unchanged package.json + cd ../../.. + done + for package in "${packages[@]}"; do + git update-index --assume-no-unchanged $package/CHANGELOG.md + git update-index --assume-no-unchanged $package/package.json + done + git add . + git commit -m "chore: release $currentTag" + git tag -a $currentTag -m "chore: release $currentTag" + git push --tags + cd packages/npm/send + sed -i 's# "release": false# "release": true#' package.json + sed -i 's# "release": "release-it --ci"# "release": "release-it --ci --no-git --no-increment"#' package.json + yarn release + + - name: Publish package to GitHub + run: yarn release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# Idea: +# run all releases in parallel doing only publishing to both places +# in this part, for each service run `yarn release` with push:false then save tag in ENV, delete all tags, grab the commit message and save it to ENV, re-stage the most recent commit, git ignore relevant files +# Lastly un-ignore all files, add and commit with saved commit message, tag and push with saved tag, run once for one service with publish:false, push:false, --no-git --no-increment flags to push the release + +# TODO: Re-check all seds +# TODO: Ensure that by the last steps where the commit happens that the only change left in package.json is the version bump + +# TODO: Need to swap things around so that we handle committing/tagging/releasing FIRST, THEN push all the npm packages in parallel +# Better for retry handling - otherwise if a publish fails to commit then the retry will fail to publish over vs this way it'll bump the version again and hopefully succeed +# +# current plan is to comment out send on main and make sure financekit works, then come back to this later. + +# diff --git a/.github/workflows/release_shared.yml b/.github/workflows/release_shared.yml index 4243860..ff41e1a 100644 --- a/.github/workflows/release_shared.yml +++ b/.github/workflows/release_shared.yml @@ -35,8 +35,7 @@ jobs: - name: Re-configure publishing for npmjs run: | sed -i 's# "registry": "https://npm.pkg.github.com/"# "registry": "https://registry.npmjs.org/"#' package.json - sed -i 's# "push": true# "push": false#' package.json - sed -i 's# "release": true# "release": false#' package.json + sed -i 's "publish": false# "publish": true#' package.json git update-index --assume-unchanged package.json git update-index --assume-unchanged CHANGELOG.md @@ -55,10 +54,10 @@ jobs: - name: Re-configure publishing for GitHub Packages run: | - git update-index --no-assume-unchanged package.json git update-index --no-assume-unchanged CHANGELOG.md - git checkout package.json git checkout CHANGELOG.md + git update-index --no-assume-unchanged CHANGELOG.md + sed -i 's# "registry": "https://registry.npmjs.org/"# "registry": "https://npm.pkg.github.com/"#' package.json git tag -d $(git tag -l) - name: Publish package to GitHub diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 065e348..17e26ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,10 +10,7 @@ jobs: strategy: fail-fast: false matrix: - workingDirectory: [ - "packages/npm/send", - "packages/npm/financekit", - ] + workingDirectory: ["packages/npm/send", "packages/npm/financekit"] uses: ./.github/workflows/tests_shared.yml with: workingDirectory: ${{ matrix.workingDirectory }} diff --git a/packages/npm/financekit/package.json b/packages/npm/financekit/package.json index bfab317..b304f06 100644 --- a/packages/npm/financekit/package.json +++ b/packages/npm/financekit/package.json @@ -1,6 +1,6 @@ { "name": "@candlefinance/financekit", - "version": "0.3.12", + "version": "0.0.1", "description": "A fast, low-level networking library", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -98,16 +98,16 @@ }, "release-it": { "git": { - "requiredBranch": "main", + "requiredBranch": "foobar", "commitMessage": "chore: release ${version}", "tagName": "v${version}", - "push": true + "push": false }, "npm": { - "publish": true + "publish": false }, "github": { - "release": true + "release": false }, "plugins": { "@release-it/conventional-changelog": { diff --git a/packages/npm/send/package.json b/packages/npm/send/package.json index 6d00b91..e6886aa 100644 --- a/packages/npm/send/package.json +++ b/packages/npm/send/package.json @@ -1,6 +1,6 @@ { "name": "@candlefinance/send", - "version": "0.3.14", + "version": "0.0.1", "description": "A fast, low-level networking library", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -98,16 +98,16 @@ }, "release-it": { "git": { - "requiredBranch": "main", + "requiredBranch": "foobar", "commitMessage": "chore: release ${version}", "tagName": "v${version}", - "push": true + "push": false }, "npm": { - "publish": true + "publish": false }, "github": { - "release": true + "release": false }, "plugins": { "@release-it/conventional-changelog": {