Skip to content

Commit

Permalink
feat: set up build for prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
pbogut committed Oct 4, 2023
1 parent 8707441 commit 1d8a39b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ jobs:
mkdir -p dist
cp "target/${{ matrix.build.TARGET }}/release/${binary_name}" "dist/${binary_name}-${{ matrix.build.NAME }}${extension}"
- name: Check if release should be created
shell: bash
run: |
RELEASE_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml)
OLD_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' <<< "$(git show HEAD~1:Cargo.toml)")
if [[ "$RELEASE_VERSION" == "$OLD_VERSION" ]]; then
echo "SHOULD_RELEASE=no" >> $GITHUB_ENV
else
echo "SHOULD_RELEASE=yes" >> $GITHUB_ENV
fi
- name: Build vscode extension
shell: bash
run: |
Expand All @@ -87,7 +98,11 @@ jobs:
cp "CHANGELOG.md" "vscode/"
cd "vscode"
npm install --include=dev
npx vsce package --target ${{ matrix.build.CODE_TARGET }} -o ../dist/magento2-ls.${version}.${{ matrix.build.CODE_TARGET }}.vsix
if [[ "${{ env.SHOULD_RELEASE }}" == "yes" ]]; then
npx vsce package --target ${{ matrix.build.CODE_TARGET }} -o ../dist/magento2-ls.${version}.${{ matrix.build.CODE_TARGET }}.vsix
else
npx vsce package --target ${{ matrix.build.CODE_TARGET }} -o ../dist/magento2-ls.${version}.${{ matrix.build.CODE_TARGET }}.vsix --pre-release
fi
- name: Upload dist
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -119,8 +134,6 @@ jobs:
OLD_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' <<< "$(git show HEAD~1:Cargo.toml)")
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "$OLD_VERSION -> $RELEASE_VERSION"
if [[ "$RELEASE_VERSION" == "$OLD_VERSION" ]]; then
Expand All @@ -142,3 +155,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish latest development
uses: softprops/action-gh-release@v1
if: env.SHOULD_RELEASE == 'no'
with:
files: dist/*
fail_on_unmatched_files: true
generate_release_notes: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1d8a39b

Please sign in to comment.