Add workflow to automatically create git tag on version bump (#2)

* fix devcontainer
* release workflow
* support pre tag
* deno -> main
This commit is contained in:
Copilot 2025-11-29 15:46:40 +09:00 committed by GitHub
parent d8cc1a117f
commit ee701e1bf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 55 additions and 47 deletions

View file

@ -2,7 +2,7 @@
"name": "Debian",
"image": "mcr.microsoft.com/devcontainers/base",
"features": {
"ghcr.io/devcontainers-extra/features/mise:1": {}
"ghcr.io/devcontainers-community/features/deno:1": {}
},
"customizations": {
"vscode": {
@ -10,18 +10,8 @@
"denoland.vscode-deno"
],
"settings": {
"deno.enable": true,
"deno.path": "/home/vscode/.local/share/mise/shims/deno"
"deno.enable": true
}
}
},
"postCreateCommand": "mise use -g deno"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Configure tool-specific properties.
// "customizations": {},
}
}

View file

@ -1,31 +1,52 @@
name: Release
name: Tag
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
branches: ["main"]
tags: ["pre"]
jobs:
test:
uses: ./.github/workflows/deno.yml
uses: ./.github/workflows/test.yml
release:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: get_tag
name: Get Local Tag Name
run: |
TAG_NAME=$(jq -r .version manifest.json)
if git fetch --depth 1 origin tag $TAG_NAME; then
echo "::notice::$TAG_NAME already released. skip publishing."
exit 0
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
- name: Setup Deno
uses: denoland/setup-deno@v2
- name: bump version
run: deno task version-bump
- name: Create Tag
env:
TAG_NAME: ${{ steps.get_tag.outputs.TAG_NAME }}
run: |
git config user.email "o@kbn.one"
git config user.name "github action"
git tag $TAG_NAME
git push origin $TAG_NAME
- run: deno task build
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" manifest.json versions.json main.js --generate-notes
run: |
REF_NAME="${{ github.ref_name }}"
PRE_RELEASE_FLAG=""
if [[ "$REF_NAME" == *pre* ]]; then
PRE_RELEASE_FLAG="--prerelease"
fi
gh release create "$TAG_NAME" manifest.json versions.json main.js --generate-notes $PRE_RELEASE_FLAG

View file

@ -1,21 +1,16 @@
name: Test
on:
push:
branches: ["deno"]
pull_request:
branches: ["deno"]
workflow_call:
permissions:
contents: read
pull_request:
branches: ["main"]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup repo
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

View file

@ -1,4 +1,4 @@
Copyright (C) 2020-2025 by Dynalist Inc.
Copyright (C) 2020-2025 by kuboon.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

View file

@ -2,7 +2,7 @@
"tasks": {
"dev": "deno run --allow-env --allow-read --allow-write --allow-run --allow-net=esm.sh esbuild.config.ts",
"build": "deno task dev production",
"version": "deno run --allow-read=. --allow-write=versions.json version-bump.ts && git add manifest.json versions.json"
"version-bump": "deno run --allow-read=. --allow-write=versions.json version-bump.ts && git add manifest.json versions.json"
},
"compilerOptions": {
"noImplicitAny": true,
@ -26,6 +26,7 @@
},
"imports": {
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.2.0",
"@std/semver": "jsr:@std/semver@^1.0.7",
"builtin-modules": "npm:builtin-modules@5.0.0",
"esbuild": "npm:esbuild@^0.27.0",
"moment": "npm:moment@^2.30.1",

View file

@ -5,6 +5,7 @@
"jsr:@deno/loader@~0.3.3": "0.3.10",
"jsr:@std/internal@^1.0.12": "1.0.12",
"jsr:@std/path@^1.1.1": "1.1.3",
"jsr:@std/semver@^1.0.7": "1.0.7",
"npm:@types/node@*": "22.12.0",
"npm:builtin-modules@5.0.0": "5.0.0",
"npm:esbuild@0.27": "0.27.0",
@ -33,6 +34,9 @@
"dependencies": [
"jsr:@std/internal"
]
},
"@std/semver@1.0.7": {
"integrity": "7d5f65391762dc4358abde80fc3354086ddb40101f140295e60f290c138887d0"
}
},
"npm": {
@ -287,6 +291,7 @@
"workspace": {
"dependencies": [
"jsr:@deno/esbuild-plugin@^1.2.0",
"jsr:@std/semver@^1.0.7",
"npm:builtin-modules@5.0.0",
"npm:esbuild@0.27",
"npm:moment@^2.30.1",

View file

@ -1,17 +1,17 @@
/// <reference lib="deno.ns" />
import { equals, parse } from "@std/semver";
const manifest = JSON.parse(Deno.readTextFileSync("manifest.json"));
const { minAppVersion, version } = manifest;
const versions = JSON.parse(Deno.readTextFileSync("versions.json"));
if (version in versions) {
console.info(`Version ${version} already exists in versions.json`);
Deno.exit();
}
const latestMinAppVersion = Object.values<string>(versions).slice(-1)[0];
if (equals(parse(minAppVersion), parse(latestMinAppVersion))) Deno.exit(0);
// update versions.json with target version and minAppVersion from manifest.json
versions[version] = minAppVersion;
Deno.writeTextFileSync("versions.json", JSON.stringify(versions, null, "\t"));
console.info(
`Run 'git tag ${version}; git push origin ${version}' after git commit & push to create a new release.`,
Deno.writeTextFileSync(
"versions.json",
JSON.stringify(versions, null, "\t") + "\n",
);

View file

@ -1,7 +1,3 @@
{
"1.0.0": "0.15.0",
"1.0.1": "0.15.0",
"1.0.2": "1.10.0",
"1.0.3": "1.10.0",
"1.0.4": "1.10.0"
}