Skip to content

Publish Artifact Bundle #20

Publish Artifact Bundle

Publish Artifact Bundle #20

name: Publish Artifact Bundle
on:
workflow_call:
inputs:
binary_name:
required: true
type: string
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string
# Enables manually running this workflow from the Actions tab
workflow_dispatch:
inputs:
binary_name:
required: true
type: string
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string
jobs:
publish:
name: Publish Artifact Bundle
runs-on: macOS-15
env:
PLUGIN_VERSION: ${{ inputs.binary_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6
with:
path: ${{ inputs.binary_name }}
- name: Get latest binaries
run: |
gh release download ${{ inputs.binary_version }} \
-R "${{ inputs.binary_repo }}" \
-p "tuist.zip" \
-D "${{ inputs.binary_name }}/Resources"
- name: Unzip Tuist
run: |
7z x "${{ inputs.binary_name }}/Resources/tuist.zip" -o"${{ inputs.binary_name }}/Resources/template.artifactbundle"
- name: Update GitHub Env Vars
run: |
# The example binary includes a leading 'v' in the release version number. We drop it on the next line.
echo "ARTIFACT_NAME=${{ inputs.binary_name }}.artifactbundle.zip" >> $GITHUB_ENV
echo "ARTIFACT_PATH=${{ inputs.binary_name }}/Resources/template.artifactbundle" >> $GITHUB_ENV
echo "ESCAPED_PLUGIN_REPO=$(echo "${{ inputs.plugin_repo }}" | sed 's/\//\\\//g')" >> $GITHUB_ENV
- name: Set info.json version
run: |
sed -i '' "s/<VERSION>/${{ env.PLUGIN_VERSION }}/g" ${{ env.ARTIFACT_PATH }}/info.json
sed -i '' "s/<TEMPLATE>/${{ inputs.binary_name }}/g" ${{ env.ARTIFACT_PATH }}/info.json
- name: Add executable permissions
run: |
# The example binaries for MacOS need the executable permission added.
chmod +x "${{ env.ARTIFACT_PATH }}/${{ inputs.binary_name }}"
- name: Zip Artifact Bundle
working-directory: ${{ env.ARTIFACT_PATH }}
run: |
7z a -tzip -mx=9 "${{ env.ARTIFACT_NAME }}" *
- name: Reset Git Repo
working-directory: ${{ inputs.binary_name }}
run: |
git reset --hard
- name: Update Package.swift
run: |
sed -i '' "s/checksum: \".*\"/checksum: \"$(shasum -a 256 '${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}' | sed 's/ .*//')\"/g" ${{ inputs.binary_name }}/Package.swift
sed -i '' -E "s/\/[0-9]+\.[0-9]+\.[0-9]+\//\/${{ env.PLUGIN_VERSION }}\//" ${{ inputs.binary_name }}/Package.swift
sed -i '' -E "s/(https:\/\/github.com\/${{ env.ESCAPED_PLUGIN_REPO }}.git\", exact: \")([0-9]+\.[0-9]+\.[0-9]+)/\1${{ env.PLUGIN_VERSION }}/" ${{ inputs.binary_name }}/README.md
- name: Push Changes to GitHub
working-directory: ${{ inputs.binary_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "Updating ${{ inputs.binary_name }} to ${{ env.PLUGIN_VERSION }}"
git push origin
- name: Get Release Notes from Binary Repo
run: |
gh release view ${{ inputs.binary_version }} \
-R "${{ inputs.binary_repo }}" \
--json body \
--jq '.body' > release_notes.md
- name: Create GitHub Release
run: |
COMMIT_SHA=$(git -C ${{ inputs.binary_name }} rev-parse HEAD)
echo "$COMMIT_SHA"
gh release create ${{ env.PLUGIN_VERSION }} \
-R ${{ inputs.plugin_repo }} \
--target "$COMMIT_SHA" \
--notes-file release_notes.md \
"${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}"