Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate release process #68

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 32 additions & 69 deletions .github/workflows/build-vsix.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
name: build-vsix

on:
pull_request_target:
types:
- closed
branches:
- main

env:
RELEASE_VERSION: 0.0.1

workflow_dispatch:
branches: main
inputs:
tag:
description: 'Release Tag. This is in the form xx.yy.zz'
required: true
jobs:
build-vsix:
# if: (startsWith(github.head_ref, 'release-') && github.event.pull_request.merged == true)
if: (github.event.pull_request.merged == true)
runs-on: ubuntu-latest
env:
CI_COMMIT_AUTHOR: CentML
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.HABITAT_AWS_ACCESS_KEY }}
aws-region: ${{ secrets.HABITAT_AWS_REGION }}
aws-secret-access-key: ${{ secrets.HABITAT_AWS_SECRET_ACCESS_KEY }}

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

Expand All @@ -38,65 +28,38 @@ jobs:
run: |
npm install -g @vscode/vsce

- name: Build VSIX
- name: Create release branch
run: |
scripts/build_vsix.sh
git branch release/${{ github.event.inputs.tag }}

- name: Set RELEASE_VERSION
- name: Update version number
run: |
RELEASE_VERSION=$(node -p "require('./deepview-explore/package.json').version")
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
pushd deepview-explore/
npm version ${{ github.event.inputs.tag }}
popd

- name: Upload vsix artifact
uses: actions/upload-artifact@v3
with:
name: deepview-explore-${{ env.RELEASE_VERSION }}.vsix
path: deepview-explore/deepview-explore-${{ env.RELEASE_VERSION }}.vsix
- name: Commit updated version number and tag it
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "username@users.noreply.github.com"
git commit -am "Release version ${{ github.event.inputs.tag }}"
git push origin release/${{ github.event.inputs.tag }}
git tag ${{ github.event.inputs.tag }}

- name: Upload vsix artifact to S3
- name: Build VSIX
run: |
aws s3 cp deepview-explore/deepview-explore-${{ env.RELEASE_VERSION }}.vsix s3://centml-releases/deepview-explore/
scripts/build_vsix.sh

update-index:
name: Update index.html in S3 bucket
needs: build-vsix
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
- name: Upload vsix artifact
uses: actions/upload-artifact@v3
with:
aws-access-key-id: ${{ secrets.HABITAT_AWS_ACCESS_KEY }}
aws-region: ${{ secrets.HABITAT_AWS_REGION }}
aws-secret-access-key: ${{ secrets.HABITAT_AWS_SECRET_ACCESS_KEY }}

- name: Fetch repository
uses: actions/checkout@v3
name: deepview-explore-${{ github.event.inputs.tag }}.vsix
path: deepview-explore/deepview-explore-${{ github.event.inputs.tag }}.vsix

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dominate
- name: Publish to VSCode Marketplace
run: |
pip3 install dominate
vsce package -p {{ secrets.AZURE_PAT }} -i deepview-explore-${{ github.event.inputs.tag}}.vsix

- name: Download all versions of DeepView-Explore from S3
run : |
mkdir vsix
cd vsix
aws s3 cp s3://centml-releases/deepview-explore/ . --recursive --exclude "*" --include "*.vsix"

- name: Create index.html
run: |
file_list=(deepview-explore-*.vsix)
formatted_file_list=$(basename -a ${file_list[@]})
cd vsix
python3 ../scripts/create_index.py deepview-explore -f $formatted_file_list

- name: Upload index.html to S3
run: |
aws s3 cp vsix/index.html s3://centml-releases/deepview-explore/

publish-release:
name: Publish Release
Expand All @@ -116,16 +79,16 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: deepview-explore-${{ env.RELEASE_VERSION }}.vsix
name: deepview-explore-${{ github.event.inputs.tag }}.vsix
path: dist

- name: Publish a release
run: |
RELEASE_NOTES="$(git log $(git describe --abbrev=0 --tags --always).. --merges --pretty=format:"%s %b" | cut -f 4,7- -d ' ')"
echo "Autogenerated Release Notes:"
echo "$RELEASE_NOTES"
RELEASE_ARTIFACTS=$(find ./dist -name "*${{ env.RELEASE_VERSION }}*" -type f | paste -s -d ' ' - )
VERSION_TAG="v${{ env.RELEASE_VERSION }}"
RELEASE_ARTIFACTS=$(find ./dist -name "*${{ github.event.inputs.tag }}*" -type f | paste -s -d ' ' - )
VERSION_TAG="v${{ github.event.inputs.tag }}"
gh auth login --with-token <<< "${{ secrets.GH_TOKEN }}"
gh release create "$VERSION_TAG" \
--title "$VERSION_TAG" \
Expand Down