Release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_run: | |
workflows: ["Test and Build VSCode"] | |
types: | |
- completed | |
jobs: | |
package: | |
name: Package | |
runs-on: ubuntu-latest | |
outputs: | |
packageName: ${{ steps.setup.outputs.packageName }} | |
tag: ${{ steps.setup-tag.outputs.tag }} | |
version: ${{ steps.setup-tag.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ steps.node_version.outputs.nvmrc }} | |
- name: Install dependencies | |
run: npm i | |
- name: Run Rollup | |
run: npm run rollupci | |
- name: List contents of out/compiled directory (for debugging) | |
run: ls -R out/compiled | |
- name: Install vsce | |
run: npm install -g @vscode/vsce | |
- name: Setup package path | |
id: setup | |
run: echo "::set-output name=packageName::$(node -e "console.log(require('./package.json').name + '-' + require('./package.json').version + '.vsix')")" | |
- name: Package | |
env: | |
VSIX_PACKAGE_PATH: ${{ steps.setup.outputs.packageName }} | |
run: vsce package | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.setup.outputs.packageName }} | |
path: ${{ steps.setup.outputs.packageName }} | |
- name: Setup tag | |
id: setup-tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "release/0") | |
current_number=$(echo $latest_tag | sed 's/release\///') | |
next_number=$((current_number + 1)) | |
new_tag="release/$next_number" | |
echo "tag: $new_tag" | |
echo "::set-output name=tag::$new_tag" | |
version=$(node -p "require('./package.json').version") | |
echo "::set-output name=version::$version" | |
shell: bash | |
publishGH: | |
name: Publish to GitHub releases | |
runs-on: ubuntu-latest | |
needs: package | |
if: startsWith(needs.package.outputs.tag, 'release/') && needs.package.outputs.tag != github.ref | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.package.outputs.packageName }} | |
- name: Generate unique tag | |
id: generate_tag | |
run: | | |
timestamp=$(date +%Y%m%d%H%M%S) | |
echo "::set-output name=unique_tag::release-${{ needs.package.outputs.version }}-$timestamp" | |
- name: Create tag | |
id: create-tag | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git tag ${{ steps.generate_tag.outputs.unique_tag }} | |
git push origin ${{ steps.generate_tag.outputs.unique_tag }} | |
echo "::set-output name=tag::${{ steps.generate_tag.outputs.unique_tag }}" | |
# - name: Commit tagger | |
# uses: tvdias/[email protected] | |
# with: | |
# repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# tag: ${{ needs.package.outputs.tag }} | |
- name: Create Release | |
id: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.create-tag.outputs.tag }} | |
release_name: Release ${{ needs.package.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Upload assets to a Release | |
uses: AButler/[email protected] | |
with: | |
files: ${{ needs.package.outputs.packageName }} | |
release-tag: ${{ needs.create_tag.outputs.tag }} | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |