production #99
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: Deploy | |
on: deployment | |
permissions: | |
contents: read | |
jobs: | |
package: | |
if: github.event.deployment.environment == 'production' | |
name: Create package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
id: go | |
- name: Compile gauge | |
run: go run build/make.go --all-platforms --skip-windows | |
- name: Create distro | |
run: | | |
go run build/make.go --distro --all-platforms --skip-windows | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gauge-non-windows-artifact | |
path: ./deploy | |
windows-package: | |
name: Create windows package | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
id: go | |
- name: Prep installer generation | |
shell: powershell | |
run: | | |
Start-Sleep -Milliseconds 1 | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
Invoke-WebRequest "https://sourceforge.net/projects/nsis/files/NSIS%203/3.06.1/nsis-3.06.1-strlen_8192.zip/download" -UseBasicParsing -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome -Outfile "./nsis.zip" | |
Expand-Archive -Force -LiteralPath ./nsis.zip -DestinationPath "C:\Program Files (x86)\NSIS\" | |
- name: Compile gauge | |
run: | | |
go run build/make.go --verbose --all-platforms | |
Get-ChildItem -Recurse .\bin | |
- name: Create Distro | |
shell: pwsh | |
run: | | |
go run build/make.go --distro --bin-dir bin\windows_amd64 | |
go run build/make.go --distro --bin-dir bin\windows_386 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gauge-windows-artifact | |
path: ./deploy | |
gauge-version: | |
name: Upload gauge version | |
runs-on: ubuntu-latest | |
needs: [package, windows-package] | |
env: | |
GITHUB_TOKEN: '${{ secrets.GAUGEBOT_GITHUB_TOKEN }}' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gauge-non-windows-artifact | |
path: ./deploy | |
- name: fetch gauge version | |
run: | | |
cd deploy | |
version=$(ls gauge-*-linux.x86.zip | sed 's/gauge-//' | sed 's/-linux.*//') | |
if [ -z "$version" ]; then | |
echo "Gauge version is not set" | |
exit 1 | |
fi | |
echo $version > ../version.txt | |
- name: upload gauge version | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gauge-version | |
path: ./version.txt | |
github-release: | |
runs-on: ubuntu-latest | |
needs: [gauge-version] | |
env: | |
GITHUB_TOKEN: '${{ secrets.GAUGEBOT_GITHUB_TOKEN }}' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gauge-non-windows-artifact | |
path: ./deploy | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gauge-windows-artifact | |
path: ./deploy | |
- name: Fetch gauge version | |
uses: actions/download-artifact@v3 | |
with: | |
name: gauge-version | |
path: . | |
- name: Set gauge version | |
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV | |
- name: update release note | |
run: | | |
echo "---------------------------" | |
echo "Creating release v$version" | |
echo "---------------------------" | |
cd deploy | |
echo -e "Gauge v$GAUGE_VERSION\n\n" > desc.txt | |
release_description=$(ruby -e "$(curl -sSfL https://github.com/getgauge/gauge/raw/master/build/create_release_text.rb)" getgauge gauge) | |
echo "$release_description" >> desc.txt | |
echo "Creating new draft for release v$GAUGE_VERSION" | |
hub release create -F ./desc.txt "v$GAUGE_VERSION" | |
rm -rf desc.txt | |
sleep 10 | |
echo "---------------------------" | |
echo "Uploading artifacts" | |
echo "---------------------------" | |
for artifact in `ls gauge-*`; do | |
echo $artifact | |
hub release edit -m "" -a $artifact v$GAUGE_VERSION | |
if [ $? -ne 0 ]; then | |
exit 1 | |
fi | |
done | |
pypi-release: | |
runs-on: ubuntu-latest | |
needs: [gauge-version] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' # caching pip dependencies | |
- name: Fetch gauge version | |
uses: actions/download-artifact@v3 | |
with: | |
name: gauge-version | |
path: . | |
- name: Set gauge version | |
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV | |
- name: Deploy to pypi | |
env: | |
PYPI_USER: ${{ secrets.PYPI_USER }} | |
GAUGE_PACKAGE_NAME: getgauge-cli | |
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
cd build/pip | |
pip install -r requirements.txt | |
python build.py --dist | |
gauge_package=`ls dist/$GAUGE_PACKAGE_NAME-$GAUGE_VERSION.tar.gz` | |
python -m twine upload -u $PYPI_USER -p $PYPI_PASSWORD $gauge_package | |
npm-release: | |
runs-on: ubuntu-latest | |
needs: [gauge-version] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: 'build/npm/package-lock.json' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Fetch gauge version | |
uses: actions/download-artifact@v3 | |
with: | |
name: gauge-version | |
path: . | |
- name: Set gauge version | |
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV | |
- name: Setup Git User | |
run: | | |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" | |
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | |
- name: Deploy npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
cd build/npm | |
npm version $GAUGE_VERSION | |
npm publish --access=public | |
choco-release: | |
runs-on: ubuntu-latest | |
needs: [gauge-version] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- name: Fetch gauge version | |
uses: actions/download-artifact@v3 | |
with: | |
name: gauge-version | |
path: . | |
- name: Set gauge version | |
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV | |
shell: bash | |
- name: Clone chocolatey-packages | |
run: | | |
git clone https://github.com/getgauge/chocolatey-packages | |
- name: Deploy to Gauge $GAUGE_VERSION to choco | |
shell: pwsh | |
env: | |
API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: | | |
cd chocolatey-packages | |
$Env:GAUGE_VERSION | Set-Content version | |
cd gauge | |
./package.ps1 | |
choco push "gauge.$Env:GAUGE_VERSION.nupkg" --apikey=$Env:API_KEY --source=https://push.chocolatey.org/ | |
brew-release: | |
runs-on: ubuntu-latest | |
needs: [gauge-version] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- name: Set up Ruby 3.1.4 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1.4 | |
- name: Fetch gauge version | |
uses: actions/download-artifact@v3 | |
with: | |
name: gauge-version | |
path: . | |
- name: Set gauge version | |
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV | |
- name: Update brew formula | |
env: | |
HOMEBREW_GITHUB_USER_NAME: ${{ secrets.HOMEBREW_GITHUB_USER_NAME }} | |
HOMEBREW_GITHUB_USER_EMAIL: ${{ secrets.HOMEBREW_GITHUB_USER_EMAIL }} | |
GITHUB_TOKEN: ${{ secrets.GAUGEBOT_GITHUB_TOKEN }} | |
run: | | |
cd build/brew | |
bash create_brew_pr.sh |