Skip to content

Commit

Permalink
feat(ci): version with CI
Browse files Browse the repository at this point in the history
  • Loading branch information
teomrd committed Nov 2, 2024
1 parent a78fe6d commit 3efed7b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,40 @@ on:
- main
- deno
jobs:
dry-versioning:
runs-on: ubuntu-22.04
outputs:
new_tag: ${{ steps.dry-versioning.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version
uses: anothrNick/github-tag-action@1.67.0
id: dry-versioning
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
DRY_RUN: true
build-and-deploy:
runs-on: ubuntu-latest
needs:
- dry-versioning
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
env:
NEW_VERSION: ${{needs.dry-versioning.outputs.new_tag}}
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: make version
- name: ✌️ Set version environment variable
shell: bash
run: echo "NEW_VERSION=${{ env.NEW_VERSION }}" >> $GITHUB_ENV
- run: make build
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MAKE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

.DEFAULT_GOAL := dev

.PHONY : install dev audits deploy serve version build deploy clean
.PHONY : install dev audits deploy serve build deploy clean

install:
deno install
Expand Down Expand Up @@ -39,9 +39,6 @@ clean:
serve: build
serve $(MAKE_DIR)/dist

version:
$(MAKE_DIR)/scripts/version.sh

build: install
$(MAKE_DIR)/scripts/build.sh

Expand Down
7 changes: 5 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as esbuild from "npm:esbuild";
import miropad from "../package.json" with { type: "json" };

const VERSION = Deno.env.get("NEW_VERSION")

console.log('Deno got VERSION 👉', VERSION);

const result = await esbuild.build({
entryPoints: ["./src/index.ts"],
Expand All @@ -19,7 +22,7 @@ const result = await esbuild.build({
},
define: {
TITLE_NAME: JSON.stringify("✍️ MiroPad"),
VERSION: JSON.stringify(miropad.version),
VERSION: JSON.stringify(VERSION),
global: "globalThis",
},
});
Expand Down
2 changes: 0 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

NEW_VERSION=$(jq -r .version ./package.json)

echo -e "🛠️ Building ${COLOR_GREEN}MiroPad${NO_COLOR} v${COLOR_RED}${NEW_VERSION}${NO_COLOR} \n"

mkdir -p ./dist
Expand Down
9 changes: 0 additions & 9 deletions scripts/version.sh

This file was deleted.

0 comments on commit 3efed7b

Please sign in to comment.