diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..3e9ab9d --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,14 @@ +name: setup + +runs: + using: composite + steps: + - uses: actions/setup-node@v4 + with: + node-version: "18" + - run: npm i + shell: bash + - run: npm run build + shell: bash + - run: echo "VERSION=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV" + shell: bash diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2d42c93..08ddc34 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,37 +1,53 @@ name: pipeline -on: [push] +on: + push: + branches: + - master + pull_request: jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "18" - - run: npm i + - uses: ./.github/actions/setup - run: npm run generate - run: "[[ -z $(git status --porcelain) ]]" - run: npm run type - run: npm run lint - run: npm run format - release: + release-check: runs-on: ubuntu-latest needs: check - if: github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[release]') + if: github.ref == 'refs/heads/master' && github.repository_owner == 'harrydowning' + steps: + - run: true + release: + runs-on: ubuntu-latest + needs: release-check + if: contains(github.event.head_commit.message, '[release]') && !contains(github.event.head_commit.message, '[pre-release]') steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "18" - - run: npm i - - run: npm run build + - uses: ./.github/actions/setup - run: npx vsce package - - run: echo "VERSION=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV" - run: gh release create v$VERSION --generate-notes yaml-embedded-languages-$VERSION.vsix env: GH_TOKEN: ${{ github.token }} - run: npx vsce publish env: VSCE_PAT: ${{ secrets.VSCE_PAT }} + pre-release: + runs-on: ubuntu-latest + needs: release-check + if: contains(github.event.head_commit.message, '[pre-release]') && !contains(github.event.head_commit.message, '[release]') + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - run: npx vsce package --pre-release + - run: gh release create v$VERSION --prerelease --generate-notes yaml-embedded-languages-$VERSION.vsix + env: + GH_TOKEN: ${{ github.token }} + - run: npx vsce publish --pre-release + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6acbfe0..35dd933 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,10 +13,11 @@ Thank you for taking an interest in contributing to this project. All contributi - Implement changes, noting that `package.json` is partially generated and `syntaxes` is fully generated so relevant changes to these should be made in `src` - Run `npm run generate` to update `package.json` and `syntaxes` +- Run `npm run build` to update `dist/extension.js` - Use F5 within VS Code to test the extension ## Release Workflow - Update `version` in `package.json` and run `npm i` to update `package-lock.json` -- Update `CHANGELOG.md` +- Update `CHANGELOG.md` (ensure version links are set) - Merge to master with `[release]` in the commit message