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

chore: publish main package #532

Merged
merged 9 commits into from
Jan 25, 2024
Merged
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
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
Loading