Skip to content

Commit

Permalink
Updated workflow to upload artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
nawaz1991 committed Jul 9, 2024
1 parent 519716e commit 2f40b20
Showing 1 changed file with 34 additions and 45 deletions.
79 changes: 34 additions & 45 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,53 @@
name: Create and Upload Release
name: Release

on:
push:
tags:
- '*'
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true
submodules: true # Include submodules
fetch-depth: 0

- name: Set up Git
- name: Create tar.gz archive
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
mkdir -p release
git archive --format=tar.gz --prefix=cpp-oasvalidator-${GITHUB_REF#refs/tags/}/ HEAD > release/cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz
cd release
tar -xzf cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz
git submodule foreach --recursive 'git archive --format=tar.gz --prefix=$path/ HEAD > ../$path.tar.gz'
for f in *.tar.gz; do tar -xzf "$f"; done
rm *.tar.gz
cd ..
tar -czf cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz -C release .
- name: Create release archives
- name: Create zip archive
run: |
TAG=${GITHUB_REF#refs/tags/}
# Create tar.gz archive
git archive --format=tar.gz --prefix=cpp-oasvalidator-${TAG}/ -o cpp-oasvalidator-${TAG}.tar.gz ${TAG}
# Create zip archive
git archive --format=zip --prefix=cpp-oasvalidator-${TAG}/ -o cpp-oasvalidator-${TAG}.zip ${TAG}
# Include submodules
TEMP_DIR=$(mktemp -d)
git clone --recursive . $TEMP_DIR/cpp-oasvalidator-${TAG}
# Add submodule content to tar.gz archive
tar -czf cpp-oasvalidator-${TAG}-with-submodules.tar.gz -C $TEMP_DIR cpp-oasvalidator-${TAG}
mv cpp-oasvalidator-${TAG}-with-submodules.tar.gz cpp-oasvalidator-${TAG}.tar.gz
# Add submodule content to zip archive
(cd $TEMP_DIR && zip -r cpp-oasvalidator-${TAG}-with-submodules.zip cpp-oasvalidator-${TAG})
mv $TEMP_DIR/cpp-oasvalidator-${TAG}-with-submodules.zip cpp-oasvalidator-${TAG}.zip
# Clean up
rm -rf $TEMP_DIR
mkdir -p release
git archive --format=zip --prefix=cpp-oasvalidator-${GITHUB_REF#refs/tags/}/ HEAD > release/cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip
cd release
unzip cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip
git submodule foreach --recursive 'git archive --format=zip --prefix=$path/ HEAD > ../$path.zip'
for f in *.zip; do unzip "$f"; done
rm *.zip
cd ..
zip -r cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip release
- name: Upload tar.gz to release
uses: svenstaro/upload-release-action@v2
- name: Upload Release Assets
uses: actions/upload-artifact@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cpp-oasvalidator-${TAG}.tar.gz
asset_name: cpp-oasvalidator-${TAG}.tar.gz
tag: ${{ github.ref }}
overwrite: true
body: "Release ${TAG}"
name: release-asset-tar
path: cpp-oasvalidator-${GITHUB_REF#refs/tags/}.tar.gz

- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
- name: Upload Release Assets
uses: actions/upload-artifact@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cpp-oasvalidator-${TAG}.zip
asset_name: cpp-oasvalidator-${TAG}.zip
tag: ${{ github.ref }}
overwrite: true
body: "Release ${TAG}"
name: release-asset-zip
path: cpp-oasvalidator-${GITHUB_REF#refs/tags/}.zip

0 comments on commit 2f40b20

Please sign in to comment.