Skip to content

Commit

Permalink
chore: publish main package (#532)
Browse files Browse the repository at this point in the history
# Description

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.

## Link to issue

Please add a link to any relevant issues/tickets.

## Type of change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Refactor (non-breaking change that updates existing functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Comments have been added/updated

Please delete options that are not relevant.

## Test plan (required)

Demonstrate the code is solid. Which commands did you test with and what
are the expected results?
Which tests have you added or updated? Do the tests cover all of the
changes included in this PR?

## Screenshots/Screencaps

Please add previews of any UI Changes.

---------

Co-authored-by: Zeeshan Lakhani <[email protected]>
  • Loading branch information
hugomrdias and zeeshanlakhani authored Jan 25, 2024
1 parent f2634eb commit db6e1f3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 282 deletions.
63 changes: 51 additions & 12 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
binary-builds:
if: >
startsWith(github.event.release.name, 'homestar-runtime') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
include: LICENSE,README.md
token: ${{ secrets.GITHUB_TOKEN }}

npm-publish:
npm-publish-arch:
needs: binary-builds
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
- name: Install cargo get
- name: Install cargo-get
run: cargo install cargo-get
- name: Prepare os/arch packages
shell: bash
Expand All @@ -146,21 +146,22 @@ jobs:
echo "node_pkg=${node_pkg}" >> "$GITHUB_ENV"
cd homestar-runtime/npm
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
envsubst < package-json-arch.tmpl > "${node_pkg}/package.json"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.target }}
path: "homestar-runtime/npm/${{ env.node_pkg }}/bin"
- name: Publish production
- name: Publish arch packages to production
if: github.event_name == 'release' && github.event.action == 'published'
run: |
cp homestar-runtime/README.md "homestar-runtime/npm/${{ env.node_pkg }}"
cd "homestar-runtime/npm/${{ env.node_pkg }}"
chmod +x bin/${{ matrix.bin }}
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish RC
- name: Publish arch packages RC
if: github.event_name == 'workflow_dispatch'
run: |
cp homestar-runtime/README.md "homestar-runtime/npm/${{ env.node_pkg }}"
Expand All @@ -171,6 +172,40 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

npm-publish-main:
needs: npm-publish-arch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
- name: Install cargo get
run: cargo install cargo-get
- name: Publish main package to production
if: github.event_name == 'release' && github.event.action == 'published'
run: |
export node_version=$(cargo get workspace.package.version)
cp homestar-runtime/README.md homestar-runtime/npm/base
cd homestar-runtime/npm
envsubst < package-json-base.tmpl > "base/package.json"
cd base
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish main package RC
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
run: |
export node_version="$(cargo get workspace.package.version)-rc.$(date +%s)"
cp homestar-runtime/README.md homestar-runtime/npm/base
cd homestar-runtime/npm
envsubst < package-json-baserc.tmpl > "base/package.json"
cd base
npm publish --access public --tag rc
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

build-packages:
needs: binary-builds
runs-on: ubuntu-latest
Expand Down Expand Up @@ -240,7 +275,7 @@ jobs:
docker-build:
if: >
startsWith(github.event.release.name, 'homestar-runtime') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
(github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
Expand All @@ -267,10 +302,14 @@ jobs:
sudo apt-get clean
sudo rm -rf /usr/share/dotnet
- name: Get Current Version
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
- name: Install cargo-get
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
run: cargo install cargo-get

- name: Set Current Version
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
id: crate-version
run: echo version=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "homestar-runtime") | .version') >> $GITHUB_OUTPUT
run: echo version=$(cargo get workspace.package.version)-rc.$(date +%s) >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -298,7 +337,7 @@ jobs:
type=sha
- name: Metadata
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
id: meta-dispatch
uses: docker/metadata-action@v5
with:
Expand All @@ -322,7 +361,7 @@ jobs:
labels: ${{ steps.meta-release.outputs.labels }}

- name: Docker Build & Push
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-publish)
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.force-builds)
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
Expand Down
Loading

0 comments on commit db6e1f3

Please sign in to comment.