Skip to content

Commit

Permalink
update github actions. one for testing and another for automatically …
Browse files Browse the repository at this point in the history
…making a release from tags
  • Loading branch information
ozgurakgun committed Nov 19, 2023
1 parent c9aa717 commit 58d9222
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 13 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Make a release

on:
workflow_dispatch: # can be triggered manually
push:
tags:
- "v*.*.*"
pull_request: # and for PRs (dry-run)

permissions:
contents: write

jobs:

Release:

strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:

- uses: actions/checkout@v3
name: Checkout repository


- name: Set version string to the commit hash
run: echo "RELEASE_VERSION=${{ github.sha }}" >> "$GITHUB_ENV"

- name: Set version string based on trigger (ref_name if on tag)
run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV"
if: startsWith(github.ref, 'refs/tags/')

- name: Set version string based on trigger (PR number if a PR)
run: echo "RELEASE_VERSION=${{ github.event.pull_request.number }}" >> "$GITHUB_ENV"
if: github.event_name == 'pull_request'

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- run: npm install

- run: xvfb-run -a npm test

- run: npm test

- name: Publish
if: success() && startsWith(github.ref, 'refs/tags/')
run: npm run deploy
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}

# See https://github.com/softprops/action-gh-release
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${RELEASE_VERSION}
draft: false
prerelease: false
generate_release_notes: true
28 changes: 15 additions & 13 deletions .github/workflows/workflow.yaml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
name: Run tests

on:
workflow_dispatch: # can be triggered manually
push:
branches:
- main
release:
types:
- created
pull_request:

jobs:
build:

Test:

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- run: npm install

- run: xvfb-run -a npm test
if: runner.os == 'Linux'

- run: npm test
if: runner.os != 'Linux'
- name: Publish
if: success() && startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
run: npm run deploy
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}

0 comments on commit 58d9222

Please sign in to comment.