Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-introducing send publishing #39

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 72 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

#
7 changes: 3 additions & 4 deletions .github/workflows/release_shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
10 changes: 5 additions & 5 deletions packages/npm/financekit/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions packages/npm/send/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down