Merge pull request #210 from ipinfo/usama/new-release #7
Workflow file for this run
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
# Build and release binaries for all major os/archs | |
name: Release to Github | |
on: | |
push: | |
tags: | |
- '*-*' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
release: | |
name: Release to Github | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup GO | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.20' | |
- name: Get Github App Token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.G_APP_ID }} | |
private-key: ${{ secrets.G_APP_PRIVATE_KEY }} | |
- name: Extract CLI Name and Version | |
run: | | |
# Get the tag name from the event payload | |
TAG_NAME=${{ github.ref_name }} | |
# Use a regular expression to extract the CLI name and version | |
if [[ $TAG_NAME =~ ^([^-]+)-([^-]+)$ ]]; then | |
CLI_NAME="${BASH_REMATCH[1]}" | |
CLI_VERSION="${BASH_REMATCH[2]}" | |
echo "CLI Name: $CLI_NAME" | |
echo "CLI Version: $CLI_VERSION" | |
# Add to github env | |
echo "CLI_NAME=$CLI_NAME" >> $GITHUB_ENV | |
echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV | |
else | |
echo "Invalid tag format: $TAG_NAME" | |
echo "Tag should be of format CLI-VSN. e.g. ipinfo-1.0.0" | |
exit 1 | |
fi | |
- name: Build | |
run: ./scripts/build-archive-all.sh ${{ env.CLI_NAME }} ${{ env.CLI_VERSION }} | |
- name: Generate changelog | |
run: ./scripts/changelog.sh ${{ env.CLI_NAME }} ${{ env.CLI_VERSION }} > changes.md | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
body_path: changes.md | |
files: | | |
./build/${{ env.CLI_NAME }}_${{ env.CLI_VERSION }}*.tar.gz | |
./build/${{ env.CLI_NAME }}_${{ env.CLI_VERSION }}*.zip | |
./build/${{ env.CLI_NAME }}_${{ env.CLI_VERSION }}*.deb | |
./${{ env.CLI_NAME }}/macos.sh | |
./${{ env.CLI_NAME }}/windows.ps1 | |
./${{ env.CLI_NAME }}/deb.sh |