Skip to content

Commit

Permalink
ci: add workflow for autopublishing nightly versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rszyma committed Nov 30, 2023
1 parent f7fe7a9 commit 771b0e0
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
75 changes: 75 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: publish

on:
schedule:
- cron: '30 5 * * *' # every day at 5:30 AM
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
VSCE_PAT: ${{ secrets.VSCE_ACCESS_TOKEN }}

jobs:
publish-prerelease:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup - git
run: |
git --version
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
- name: Setup - just
uses: taiki-e/install-action@just

- name: Try bump kanata
run: |
just bump_kanata
git push
- name: Setup - cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup - wasm-pack and wasm32-unknown-unknown target
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
rustup target add wasm32-unknown-unknown
- name: Setup - Node.js
uses: actions/setup-node@v3
with:
node-version: '21'
cache: 'yarn'

- name: Setup - install yarn
run: yarn

- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .version package.json --raw-output --exit-status'

- name: Increment semver patch number
id: new-version
run: curl https://raw.githubusercontent.com/rszyma/shell-semver/master/increment_version.sh -sSf | sh -s -- -p

- name: Setup - vsce
run: yarn global add vsce

- name: Build and publish
run: just pre_release ${{ steps.new-version.outputs.value }}
13 changes: 12 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bump_kanata:
HASH=$(git rev-parse --short HEAD)
cd ..
# Exit early without updating changelog if a bump notice was already added in "Unreleased" section.
! grep -q "$HASH" CHANGELOG.md
$(! grep -q "$HASH" CHANGELOG.md)
awk '/^### [0-9]/ && found==0 {found=1} found==0 && /Updated kanata to/ {next} 1' CHANGELOG.md > temp && mv temp CHANGELOG.md
just _add_to_changelog "Updated kanata to \[$HASH\]\(https\:\/\/github\.com\/jtroo\/kanata\/tree\/$HASH\)"
just _ensure_no_staged_changes
Expand All @@ -35,6 +35,17 @@ release VERSION:
git tag v{{VERSION}}
git push --tags

pre_release VERSION:
just _ensure_no_staged_changes
git checkout main
git pull
sed -i 's/\"version\": \"[^\"]*\"/\"version\": \"{{VERSION}}\"/' package.json
sed -i 's/### Unreleased/### Unreleased\n\n* no changes yet\n\n### {{VERSION}}/' CHANGELOG.md
vsce publish {{VERSION}} --pre-release
git add CHANGELOG.md package.json
git commit -m "Pre-Release v{{VERSION}}"
git push

use_local_repo:
sed -i 's/kanata\/parser/kanata-local\/parser/' kls/Cargo.toml

Expand Down

0 comments on commit 771b0e0

Please sign in to comment.